SelfEmployed.com interview question

See Leetcode 982 for the question.