Amazon interview question

pattern recognition