Bloomberg interview question

Leetcode Medium, Base 10 question