Pregunta de entrevista de Amazon

easy-medium leetcode question with help oft he interviewer