Binary tree preorder

bhaiya logic toh sahi built kiya hai par is input ke liye work nahi kar raha hai

input=8 10 -1 -1 6 9 -1 -1 7 -1 -1 3 -1 14 13 -1 -1 -1
expected output= 8 10 1 6 9 7 3 13 14
my output= 8 10 6 9 7

hello @ikshit9

your logic and code is correct.
ek baar apna input check kar lo wo sahi hai ya nahi

bhaiya waise input toh sahi hai tree built karne ke liye

your code is correct.
give input mentioned in video to verify it

sir next video mei (inorder,postorder) yahi input le rakhi hai or is input ke liye video code correct work kar raha hai par mera wala code nahi work kar raha hai.

are bhai tumhare input galat hai ,jo input diya hai tumne uske hisab se tumhare program sahi output de rha hai.
paper pe khud construct kar ke dekho

Uploading: 20210608_005415.jpg…
Sorry bhai ye meri bekar galti ke liye pata nahi aisa hai dimag ghoom raha tha jo itni faltu se mistake nahi dekh paya mei