Bloomberg interview question

Straight out of leet-code Bloomberg section