Modify the \method {KMPMatch} algorithm to maintain a variable ${maxIndex}$ which is the index of the longest prefix found, ${maxLen}$ which is the length of the longest prefix found, and ${currentLen}$ which is the length of the current prefix. Initialize all three variables to zero and modify the loop in \method {KMPMatch} as follows: \par \begin {itemize} \item If $T[i] = P[j]$, increment ${currentLen}$ \item If $T[i] \neq P[j]$ and $j > 0$, if ${currentLen} > {maxLen}$, then set ${maxLen} = {currentLen}$ and ${maxIndex} = i-j$ . In any case, reset ${currentLen} = 0$. \end {itemize} \par When the algorithm terminates, ${maxIndex}$ and ${maxLen}$ will hold the location and length of the longest prefix.