Pergunta de entrevista da empresa IBM

An algorithm question involving counting the a pattern of numbers in an array forwards and backwards