Pregunta de entrevista de Amazon

Two leetcode problems (easy to medium) difficulty