Pergunta de entrevista da empresa Meta

General algorithm questions on the more difficult side.