Why it is giving tle

for this question https://ide.codingblocks.com/s/228876

hey @harry_potter123 kindly check the first link u provided, it has code for something else


u can have a look at this code, the buildtree function especially, it will help u in fixing urs