Pergunta de entrevista da empresa LinkedIn

Standard Algorithm and DS. Medium difficulty