https://leetcode-cn.com/problems/happy-number/
class Solution {
public boolean isHappy(int n) {
Map<Integer,Integer> map=new HashMap<>();
while (next(n)!=1){
if (map.get(next(n))!=null){
return false;
}
map.put(n,next(n));
n=next(n);
}
return true;
}
public static int next(int num){
int sum=0;
while (num!=0)
{
sum=sum+(num%10)*(num%10);
num=num/10;
}
return sum;
}
}