Microsoft interview question

array problem, pattern searching