Apple interview question

Two coding exercises and some follow ups.