You are viewing a single comment's thread. Return to all comments →
This would return false. Inorder 8 -> 18 -> 10
18 > 10
As long as the last element is the last elemented "visited" and not last element passed by.
Yes, but as long as we return max values from left subtrees and min values from right subtrees and make sure they follow the rule.
I didn't do that. I just did inorder traversal recursively and made sure it was all ascending order. Passed all cases.
Mine is also a similar idea.
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Is This a Binary Search Tree?
You are viewing a single comment's thread. Return to all comments →
This would return false. Inorder 8 -> 18 -> 10
18 > 10
As long as the last element is the last elemented "visited" and not last element passed by.
Yes, but as long as we return max values from left subtrees and min values from right subtrees and make sure they follow the rule.
I didn't do that. I just did inorder traversal recursively and made sure it was all ascending order. Passed all cases.
Mine is also a similar idea.