Apple Interview Question

leetcode hard technical interview problem