Bloomberg Interview Question

I got a leetcode easy/medium type problem-solving.