Domanda di colloquio di Yahoo

Programming question, very similar to leetcode problems