Pergunta de entrevista da empresa Yahoo

Programming question, very similar to leetcode problems