Apple interview question

It is the Leetcode hard questions