Apple interview question

Data structures and algorithms coding question