Help me in solving LONGSEQ problem: ut in int

My issue

Why is it not working if we take int instead of string

My code

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		
		while(T>0){
		    int n = sc.nextInt();
		    int count0 =0;
		    int count1 =0;
		    int count =0;
		    while(n >0){
		        int temp = n%10;
		        System.out.println(temp);
		        if(temp == 0)
		        count0++;
		        else
		        count1++;
		        n = n/10;
		        count++;
		        
		        System.out.println("n : "+n);
		        System.out.println("count : " + count);
		    }
		    
		    

		    if(count1 == 1 || count0 == 1)
		    System.out.println("YES");
		    else
		    System.out.println("NO");
		    
		    T--;
		}
	}
}

Problem Link: LONGSEQ Problem - CodeChef

@jkl20cse061

  1. Comment out the unnecessary lines
System.out.println(temp);

System.out.println("n : "+n);
System.out.println("count : " + count);
  1. You need to output ‘Yes’ or ‘No’ - yeah unfortunately not in caps

  2. What if the input is only ‘1’ or ‘0’. What will your code output?
    What should it actually output?