Pregunta de entrevista de LinkedIn

Standard Algorithm and DS. Medium difficulty