Pregunta de entrevista de Chewy

Basic Data structure based problem