About this question
Hard · Algorithms & Data Structures · Quant Trader interview question · algorithms, string-matching, time-complexity, kmp
You are building a high-frequency trading system that relies on identifying specific patterns in market data to execute trades. You need to implement a string matching algorithm to quickly detect these patterns in real-time data streams. You have chosen the Knuth-Morris-Pratt (KMP) algorithm for its efficiency. Given a pattern string of length $m$ and a text string of length $n$, what is the time complexity of the KMP algorithm?