Print BST keys in given range

Output is correct but showing wrongs answer , pls tell what have i done wrong.

hi @ujj1804_1156aee80205d0bf,
check the updated code https://ide.codingblocks.com/s/659859

Sir thank you , but why my code didnt work , it gave right output , i pushed the nodes in vector and sorted them and printed them , can u give an example of a tree for which my code wont work?

@ujj1804_1156aee80205d0bf, in your code u have to just clear the vector u made in every test case as its global so it still stores prev ans

just write v.clear() in every test case

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like