Finding all the common substrings of given two strings

前端 未结 2 597
臣服心动
臣服心动 2020-12-12 18:22

I have come across a problem statement to find the all the common sub-strings between the given two sub-strings such a way that in every case you have to print the l

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 18:59

    Typically this type of substring matching is done with the assistance of a separate data structure called a Trie (pronounced try). The specific variant that best suits this problem is a suffix tree. Your first step should be to take your inputs and build a suffix tree. Then you'll need to use the suffix tree to determine the longest common substring, which is a good exercise.

提交回复
热议问题