Pregunta de entrevista de iCapital

Asked a standard leetcode question