We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d973f51 commit cde643cCopy full SHA for cde643c
leetcode/DailyQuestions/Day2.cpp
@@ -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
@@ -0,0 +1,12 @@
+ public:
+ int singleNumber(vector<int>& nums) {
+ int num = 0;
+ for(int a:nums){
+ num ^= a;
+ return num;
0 commit comments