Amazon interview question

Q: Rotton Oranges on leetcode