```
class Solution {
public:
bool isHappy(int n) {
vector<int> nums;
int temp = n;
while(temp != 1){
if (find(nums.begin(), nums.end(), temp) != nums.end())
return false;
nums.push_back(temp);
int sum = 0;
while(temp){
sum += pow((temp%10),2);
temp /= 10;
}
temp = sum;
}
return true;
}
};
```