American Express interview question

string matching algo like kmp