Uber interview question

It was leetcode standard cherry picking problem variant