Uber Interview Question

Medium leetcode difficulty. Something to do with bst