Pregunta de entrevista de Amazon

Tricky but manageable with leetcode