Epic interview question

Basic string manipulation, and big-O complexity.