cpp
class Solution {
public:
set<int>st;
bool isHappy(int n) {
while(n!=1){
vector<int>ans;
while(n>0){
int k=n%10;
if(k!=0)ans.push_back(k);
n=n/10;
}
n=0;
for(auto t:ans){
n+=t*t;
}
if(!st.count(n))st.insert(n);
else return false;
}
return true;
}
};