class Solution {

public:

bool isHappy(int n) {

set<int> setNum;

int temp;

int sum =0;

while(1){

if(setNum.find(n)!=setNum.end())

{

if(1 == n)

return true;

else

return false;

}

else

setNum.insert(n);

while(n)

{

temp = n%10;

sum +=temp*temp;

n = n/10;

}

n = sum;

sum = 0;

}

```
}
```

};