Bloomberg interview question

leetcode easy problem-not too bad