Pregunta de entrevista de Ding

An white board programming question.