Pregunta de entrevista de Goldman Sachs

I was asked on Data Structures and Algorithm mainly