Uber interview question

Typical leetcode-style question solvable with an array