Pregunta de entrevista de Infosys

Coding question on heap and graph.