Skip to content

Commit c5cabeb

Browse files
authored
leetcode daily 30th Novemver 2022 and others (#2)
1 parent d61dd19 commit c5cabeb

File tree

4 files changed

+49
-8
lines changed

4 files changed

+49
-8
lines changed

README.md

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
# ACM
2-
ACM type problems solved by me.
3-
4-
<br><br>
5-
61
**Arafat Hasan Jenin** *<opendoor.arafat[at]gmail[dot]com>*
7-
Mawlana Bhashani Science and Technology University
8-
Santosh, Tangail
92
*From Rangpur, Bangladesh*
103

114

125
<br><br>
136

14-
#### My IDs in commpetitive programming platforms
7+
#### My IDs in various problem solving platforms
158
Codeforce: [arafat_hasan](http://codeforces.com/profile/arafat_hasan/)
169
Uva: [arafat_hasan](http://uhunt.onlinejudge.org/id/859424/)
1710
HackerRank: [arafat_hasan](https://www.hackerrank.com/arafat_hasan/)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* FILE: 1207.unique_number_of_occurrences.cpp
3+
* @author: Arafat Hasan Jenin <opendoor.arafat[at]gmail[dot]com>
4+
* LINK: https://leetcode.com/problems/unique-number-of-occurrences
5+
* DATE CREATED: 30-11-22 11:49:33 (+06)
6+
* LAST MODIFIED:
7+
* VERDICT: Accepetd
8+
*/
9+
10+
class Solution {
11+
public:
12+
bool uniqueOccurrences(vector<int>& arr) {
13+
unordered_map<int, int> freq;
14+
unordered_set<int> st;
15+
for (auto i : arr) freq[i]++;
16+
for (auto i : freq) st.insert(i.second);
17+
return st.size() == freq.size();
18+
}
19+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// class Solution {
2+
// public:
3+
// int maximum69Number(int num) {
4+
// string str = to_string(num);
5+
// for (auto &c : str) {
6+
// if (c == '6') {
7+
// c = '9';
8+
// break;
9+
// }
10+
// }
11+
12+
// return stoi(str);
13+
// }
14+
//};
15+
16+
class Solution {
17+
public:
18+
int maximum69Number(int num) {
19+
int p = 1;
20+
int n = num, maxp = 0;
21+
while (n > 0) {
22+
int digit = n % 10;
23+
if (digit == 6) maxp = p;
24+
p *= 10;
25+
n /= 10;
26+
}
27+
return num + (maxp * 3);
28+
}
29+
};

0 commit comments

Comments
 (0)