Pregunta de entrevista de DistrictD

Data structure algorithm question they asked to me.