Apple Interview Question

It is the Leetcode hard questions