Apple Interview Question

med leetcode problem without real coding, but just verbal discussion