Pergunta de entrevista da empresa Apple

it was a regular expression question classic one