Domanda di colloquio di Bloomberg

Leetcode question and about medium difficulty.