Apple interview question

med leetcode problem without real coding, but just verbal discussion