Uber interview question

Rotting oranges LeetCode medium problem