Pregunta de entrevista de Okta

It is a LeetCode medium question