Pregunta de entrevista de Amazon

Two leetcode problems of medium difficulty I would say.