Pregunta de entrevista de Uber

Medium leetcode difficulty. Something to do with bst