I have use this approach to solve this problem is it a bad approach in interview time to solve this problem

// code part

public static Boolean checkSum(int n){
	
	for(int i=0;i<10005;i++){
		int sum = 0;
		while(n>0){
			sum += Math.pow(n%10,2);
			
			n = n/10;
		}
		if(sum==1){
			return true;
		}
		n = sum;
	}
	
	return false;
	
}

}

no… there is nothing wrong in ur approach… all u have to just check is if sum !=1 u will again assign it to n do that process again until some repetition is there…

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.