Pregunta de entrevista de Amazon

Leetcode easy for final round, leetcode medium/easy for OA2.