• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
September 30, 2024 |30 Views

PROBLEM OF THE DAY : 22/09/2024 | Longest Prefix Suffix

  Share   Like
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of String but also build up problem-solving skills.

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.

Examples :

Input: str = "abab" Output: 2 Explanation: "ab" is the longest proper prefix and suffix. 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/longest-prefix-suffix2527/1