why this code is giving run time error? plaindrome binary number (starter 18)

/* 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
{
// your code goes here
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t–>0)
{
int n=s.nextInt();
int arr[]=new int[n];
int det[]=new int[n];
int x=0,k=0,count=0;
for(int i=n-1;i>0;i–)
{
if(ispalindrome(i))
arr[x++]=i;
}
int sum=0;x–;int ans=0;
int y=0;
while(sum<n && ans==0)
{
if(sum==0||(arr[y]+sum)<=n)
{
sum=sum+arr[y];
det[k++]=arr[y];
count++;
}
else if((arr[y]+sum)>n)
y++;
if(sum==n)
ans=1;
}
System.out.println(count);
for(int i=0;i<k;i++)
{
System.out.print(det[i]+" ");
}
System.out.println();

	    }
}

public static boolean ispalindrome(int num)
{
   int bin=decimalToBinary(num); 
   String str=Integer.toString(bin);
   
     int len = str.length();
for(int i = 0; i < len / 2; i++)
{
    if (str.charAt(i) !=
        str.charAt(len - i - 1))
        return false;
}
return true;

}

    static int decimalToBinary(int N)
{
    int B_Number = 0;
    int cnt = 0;
    while (N != 0) {
        int rem = N % 2;
        double c = Math.pow(10, cnt);
        B_Number += rem * c;
        N /= 2;

        cnt++;
    }

    return B_Number;
}

}

Consider the test input:

1
1