I need to make tree?

@leoking please reply , you just liked , but no any reply

@leoking
//what is the mistake in my code, please review it.
import java.util.*;
public class Main {
public static void main(String args[]) {
ArrayList al=new ArrayList<>();
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int num=sc.nextInt();
al.add(num);
}
int p=0;
int i=0;
int n=1;
int siz=al.size();
while(i<siz){

		ArrayList<Integer> temp=new ArrayList<>();
		for(int j=i;j<i+n;j++){
			if(al.get(j)!=-1)
			temp.add(al.get(j));

		}
		if(temp.size()>0)
		System.out.print(temp.get(0)+" ");
		i=n;
		n=temp.size()*2;
		
	}


}

}

Bro I had said print the first column but also to replace -1 with null values
That means remove all -1 in the row until a non negative value appears.

h = (int)Math.ceil(log(siz)/log(2))
int [][] arr = new int[h][];
int n = 1,count = 0;
int i = 0,j = 0;
while(count < size)
h[j][] = new int[n];
if(al.get(count) != -1)
h[j][i++] = al.get(count++);
if(count == n){
i = 0;
n *= 2;
j++
}

@leoking??? why are you not replying of my question??

I have replied please check above

this question @leoking???

have you checked my all questions?? and you have not respond on my code ??

Brother I only have access to this question of yours. Please close this doubt if done so that I can view the others

i asked my doubt , about my code please review my code, but you have not reply on my code , you just sent the code.and i also asked a doubt regarding iterative or recursive solution (you can check above ) but you have not reply on also.

yes the code that I have sent is a correction to your code and your recursive vs iterative solution I have already answered.
Please do not put repetitive questions henceforth since you are unnecessarily elongating this doubt more than required.

you sent the code using 2d matrix, if i am using arraylist then whats the problem in my code??

Then try doing the same in arraylist style.
Create arraylist of arraylist

i have done but i am getting tle, i already sent the code , but you are not replying on my code, please review it

    import java.util.*;
    public class Main {
    public static void main(String args[]) {
    ArrayList<Integer> al=new ArrayList<>();
   Scanner sc=new Scanner(System.in); 
   while(sc.hasNext()){
  int num=sc.nextInt();
al.add(num);
  }
 int p=0;
 int i=0;
 int n=1;
int siz=al.size(); 
while(i<siz){
		ArrayList<Integer> temp=new ArrayList<>();
		for(int j=i;j<i+n;j++){
			if(al.get(j)!=-1)
			temp.add(al.get(j));

		}
		if(temp.size()>0)
		System.out.print(temp.get(0)+" ");
		i=n;
		n=temp.size()*2;
		
	}


}

}

Yes and I have already sent you the solution
Its not just conversion of arraylist to 2-D or vice versa
There are other things wrong as well in your code which I have corrected

Specifically on how you are updating n
Please first look and then respond
Dont respond blindly just by looking at the first line
And try to learn not argue

n updating on the basis of total nodes in previous level

i am not arguing , i just to want to know , why i am getting tle, whats the problem in my code.
i just want to know my mistake , then i will improve it

Likh to diya hai error bhai tu padhta nahi hai to ab mei kya karu