Pregunta de entrevista de Google

Leetcoding as usual. Nothing too difficult.