Pregunta de entrevista de Susquehanna International Group

Leetcode question was easy to medium