Apple interview question

Three rounds of leetcode medium