Apple Interview Question

medium difficulty of algorithm questions