Xero interview question

Easy/mid level leetcode style problem.