Apple interview question

fairly simple questions on algorithms, Perl strings