Uber Interview Question

It was leetcode standard cherry picking problem variant