Pregunta de entrevista de Attentive

Basic leetcode type question (easy-medium)