Can you let me now how can i improve my code since it is only passing one test case .
Recover the binary search tree
@rahul.aggarwal000005, you are swapping wrong values, what you are doing is the moment you find a node that is in wrong position you return that node along with the node you compared with but your approach fails when the other swapped node has’nt been traversed yet.
eg:-
3 4 1 -1 -1 -1 2 -1 6 -1 -1
your output :-
3 4
correct output :-
2 4