Microsoft Interview Question

array problem, pattern searching