Pregunta de entrevista de Google

I was requested to write some code on a board