Pregunta de entrevista de Intel Corporation

question from leetcode, not hard