Xero Interview Question

Easy/mid level leetcode style problem.