Pergunta de entrevista da empresa Microsoft

A medium difficulty algorithm problem