Bloomberg interview question

one from the leetcode question