Bloomberg Interview Question

leetcode medium question answered in 45 minutes