Bloomberg interview question

Leet code medium style questikns