public class Solution {
public boolean isHappy(int n) {
ArrayList<Integer>list=new ArrayList<Integer>();
while(n!=1){
int sum=0;
while(n!=0){
sum+=(int)Math.pow((n%10),2);
n/=10;
}
if(list.contains(sum) && sum!=1){
return false;
}
else{
list.add(sum);
}
n=sum;
}
return true;
}
}
Simple Java Solution

@emimayank so beautiful code. I do not know why, I should rely on from high to low to take this figure, really really silly.