Amazon interview question

find a pattern from a string