Bloomberg Interview Question

Straight out of leet-code Bloomberg section