Pregunta de entrevista de Morgan Stanley

Coding question is easy Leetcode level.