Pregunta de entrevista de Citadel

Heap based question for techincal problem