Pregunta de entrevista de Google

Data structures and a Discrete math problem.