TradingHub interview question

leetcode question relating to tree search.