Apple Interview Question

medium leetcode question has been asked