DAYS
HOUR
MINS
SEC
Error
Input:
10
/ \
5 8
/ \
2 20
Output: 1
Explanation:

Example 2:
Input:
11
/ \
3 17
\ /
4 10
Output: 1
Explanation:
By swapping nodes 11 and 10, the BST
can be fixed.
Your Task:
You don't need to take any input. Just complete the function correctBst() that takes root node as parameter. The function should not return anything, all the changes must be done in the existing tree only. BST will then be checked by driver code and 0 or 1 will be printed.
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ Number of nodes ≤ 103
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Yes