Bloomberg Interview Question

leetcode easy and medium problem