Bloomberg Interview Question

It was coding round, hence had to code in my desired language