Bloomberg interview question

A medium level leetcode coding problem.