in the range of integer, the sum of each digit will never be bigger than 900, so i used int[] which size is 1000.

we just need to get sum = 1 or sum = one of the previous sum(which means infinity loop occurred).

```
public class Solution
{
public boolean isHappy(int n)
{
int[] map = new int[1000];
while(n != 1)
{
n = getSum(n);
map[n]++;
if (map[n] > 1)
return false;
}
return true;
}
public int getSum(int num)
{
char[] temp = (num + "").toCharArray();
int sum = 0;
for (int i = 0; i < temp.length; i++)
{
sum += ((temp[i] - '0') * (temp[i] - '0'));
}
return sum;
}
}
```