Apple interview question

Find and fix a bug in the given codes