Affirm Interview Question

a leetcode-style task with some runtime constraints