Uber interview question

one of the leetcode problem from medium level, but with few changes