We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e52be90 commit 6fa9fbeCopy full SHA for 6fa9fbe
src/leetcode/HappyNumber.java
@@ -10,19 +10,19 @@ public static void main(String[] args) {
10
}
11
12
public boolean isHappy(int n) {
13
- HashSet<Integer> set = new HashSet<>();
14
- while(!set.contains(n)){
15
- set.add(n);
16
- int sq= 0;
17
- while(n>0){
18
- int digit= n%10;
19
- sq+=digit*digit;
20
- n= n/10;
21
- } System.out.println(sq);
22
- if(sq==1) return true;
23
- n=sq;
24
- }
25
- return false;
26
+ HashSet<Integer> set = new HashSet<>();
+ while(!set.contains(n)){
+ set.add(n);
+ int sq= 0;
+ while(n>0){
+ int digit= n%10;
+ sq+=digit*digit;
+ n= n/10;
+ } System.out.println(sq);
+ if(sq==1) return true;
+ n=sq;
+ }
+ return false;
27
28
0 commit comments