Incredible hulk Problem. Working for sample test cases but failing on submission

import java.util.*;
public class Main {

static void solve(int n) {

	int steps=1;
	for(int i=2; i<=n; i=i*2){
		steps *= 2;
	}
	//System.out.println("s "+steps);
	if(steps == n){
		System.out.println("1");
	}else {
		int cnt = 1 + (n-steps);
		System.out.println(cnt);
	}

}

public static void main(String args[]) {
    // Your Code Here

	Scanner sc = new Scanner(System.in);
	int t = sc.nextInt();
	while(t-- > 0) {
		int n = sc.nextInt();
		solve(n);
	}
}

}

hi @arishhaq_ae3b72621f2b5e46 buddy by mistake doubt came to me, I’m TA for cpp please ask the doubt again, sorry for the inconvenience

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.