Moody's interview question

Standard array algorithm questions