Failing one testcase

Refer for code: -

i/p
10
14 17 7 18 12 5 4 6 21 24
11 17

ur o/p

Preorder : 14 7 5 4 6 12 17 18 21 24

Nodes within range are : 6 12 14 17 ( this is wrong)

Hello @chhavibansal
For the above testcase my output is 12 14 17

Could you please help me with this code

hey i see u made a successful submission do u still havve some doubt?