• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
December 28, 2023 |200 Views
SDE Sheet - KMP
  Share   Like
Description
Discussion

This video is a part of String section under GFG SDE Sheet. 

In this video, we are given, a string of characters, find the length of the longest proper prefix which is also a proper suffix.

NOTE: Prefix and suffix can be overlapping but they should not be equal to the entire string.

Example :

Input: s = "abab"
Output: 2

Explanation: "ab" is the longest proper prefix and suffix. 

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/longest-prefix-also-suffix/
Problem: https://www.geeksforgeeks.org/problems/longest-prefix-suffix2527/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More