Pregunta de entrevista de Apple

Two coding exercises and some follow ups.