Uber interview question

Hackerrank