I am unable to understand what is wrong in this code

import java.util.;
import java.util.Arrays;
import java.math.BigInteger;
public class Main {
static HashSet set = new HashSet<>();
static boolean flag = false;
static long getCount(long n , long total , long i, long height)
{
if(i>total)
{
return 0;
}
if((i+1-(long)Math.pow(2,height)) == n-1)
{
flag = true;
return 1;
}
long ans2 = 0;
long ans1 = getCount(n, total, 2
i+1,height + 1);
if(flag == false)
ans2 = getCount(n, total, 2*i+2, height +1);
return 1+ans1+ans2;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t>0)
{
int h = sc.nextInt();
long n = sc.nextLong();
long i = 0;
long total = (long)Math.pow(2, h+1);
set.clear();
flag = false;
System.out.println(getCount(n,total,i,0));
t–;
}

}

}

@s9868121001 Can you explain your approach a bit.

Hey @s9868121001
Please paste your code on CB IDE and send it once. Some code is often lost when pasted directly. https://cb.lk/ide

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.