Google Interview Question

Data structures and a Discrete math problem.