Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

LONGEST REPEATING COMMON STRING

Правка en1, от 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

Теги dp problem, substring search, optimization, longest common substring

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Atharva2004_123 2024-03-25 10:47:03 1277 Initial revision (published)