TLE in JNEXT problem in SPOJ
int[] arr


You can probably create it only once, with maximum possible size, outside for for loop.

System.out.print(arr[ii]);


You need to use StringBuilder and output only whole string in single println call. Multiple System.out.print calls are what makes it slow.