```
public class Solution {
int[] arr = new int[10000];
int count = -1;
public boolean isHappy(int n) {
int next = 0;
while(n!=1){
while(n!=0){
next = next + (n%10)*(n%10);
n=n/10;
}
if(isInArr(next, arr, count))
return false;
arr[++count]=next;
n = next;
next=0;
}
return true;
}
public boolean isInArr(int n , int[] a, int count){
for(int i=0; i<=count; i++)
if(a[i]==n)
return true;
return false;
}
```

}