Skip to content

Commit cde643c

Browse files
committed
New Problems Added
1 parent d973f51 commit cde643c

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

leetcode/DailyQuestions/Day2.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
class Solution {
2+
3+
public:
4+
5+
int rev(int n){
6+
int sum = 0;
7+
8+
while(n){
9+
int val = n % 10;
10+
n /= 10;
11+
sum += val * val;
12+
}
13+
14+
return sum;
15+
}
16+
17+
18+
bool isHappy(int n) {
19+
20+
unordered_set<int> nums;
21+
while(1){
22+
23+
if(n == 1)
24+
return true;
25+
26+
n = rev(n);
27+
28+
if(nums.count(n) == 1)
29+
return false;
30+
31+
nums.insert(n);
32+
33+
}
34+
35+
}
36+
};
37+

leetcode/DailyQuestions/day1.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int singleNumber(vector<int>& nums) {
4+
int num = 0;
5+
6+
for(int a:nums){
7+
num ^= a;
8+
}
9+
10+
return num;
11+
}
12+
};

0 commit comments

Comments
 (0)