Two of the nodes of a Binary Search Tree (BST) are swapped. Fix (or correct) the BST.

Input Format:
First line consists of T test cases. First line of every test case consists of N, denoting number of elements in BST. Second line of every test case consists 3*N elements 2 integers and a character

Note: It is guaranteed than the given input will form BST ,except for 2 nodes that will be wrong.

Output Format:
For each testcase, in a new line, print either 0 or 1.

Your Task:
You don't need to take any input. Just complete the function correctBst() that takes node as parameter. The corrected BST will then be checked internally.

1 <= T <= 100
1 <= N <= 100


10 5 L 10 8 R  5 2 L 5 20 R
8 3 L 8 10 R 3 1 L 3 6 R 6 7 R


Testcase 1:


** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use, generate link and share the link here.

to report an issue on this page.