Pergunta de entrevista da empresa Amazon

Rotting oranges problem on leetcode. Problem 994