Citi interview question

Question based on pattern matching.