Code working fine on leetcode but here giving wrong output

bool isHappy(int n) {
set st;
while (1)
{
n = digitSum(n);
if (n == 1)
return true;
if (st.find(n) != st.end())
return false;
st.insert(n);
}
}
int digitSum(int n){
int res = 0;
while(n != 0){
int digit = n % 10;
res += digit*digit;
n /= 10;
}
return res;
}

Issue was only with output format, try to submit it if it doesn’t gets pass. Do let me know.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.