Pregunta de entrevista de ZooZ

Algorithm & DS question. Design question.