🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: String Matching — KMP and Rabin-Karp: all 10 questions

Quiz: String Matching — KMP and Rabin-Karp · Question 2 of 10

What does lps[i] store in KMP?

What does lps[i] store in KMP?

  1. A.The length of the longest proper prefix of pat[0..i] that is also a suffix of it
  2. B.The number of times pat[i] appears in the pattern
  3. C.The position of the next mismatch
  4. D.The length of the longest palindrome ending at i
Answer & explanation

Correct answer: The length of the longest proper prefix of pat[0..i] that is also a suffix of it

"Proper" means the prefix cannot be the whole of pat[0..i].

Can you get the rest right without peeking?

Take the timed Quiz: String Matching — KMP and Rabin-Karp quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →