Please read the new rule regarding the restriction on the use of AI tools. ×

LONGEST REPEATING COMMON STRING

Revision en1, by Atharva2004_123, 2024-03-25 10:47:03

longest repeating common substring can be on various types . One which I am talking about is like :-

  1. Substring- A string a is a substring of a string S if a can be obtained from S by the deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
  2. Longest Repeating — The string has longest repeating substring when it has longest length among all possible fellow substrings of its parent string.

This is an important concept to learn as it is useful in many questions : [problem:101262/B]

[problem:1584/F]

[problem:[problem:1948/D] [submission:253170793]]

Approach In these kinds of problem you need to think you reusing previous values to take desicion based on them. Think of a Dynamic Programming always in such cases. . Some question might take recursion so you can optimize them with memoization.

Complexity with DP Time : O(n^2) Space : O(n^2) (depending upon size of data structure and variables used).

Additional Resources Practice problem based on LCS

Tags dp problem, substring search, optimization, longest common substring

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Atharva2004_123 2024-03-25 10:47:03 1277 Initial revision (published)