Suppose we are given a string s1, we need to the find total number of substring(including multiple occurrences of the same substring) of s1 which are present in string s2.
Input : s1 = aab s2 = aaaab Output :6 Substrings of s1 are ["a", "a", "b", "aa", "ab", "aab"]. These all are present in s2. Hence, answer is 6. Input :s1 = abcd s2 = swalencud Output :3
The idea is to consider all substrings of s1 and check if it present in s2.
- Number of substrings of a string
- Number of even substrings in a string of digits
- Sum of all substrings of a string representing a number | Set 1
- Number of substrings divisible by 6 in a string of integers
- Number of substrings with odd decimal value in a binary string
- Rearrange the string to maximize the number of palindromic substrings
- Split the binary string into substrings with equal number of 0s and 1s
- Count the number of vowels occurring in all the substrings of given string
- Count number of substrings of a string consisting of same characters
- Given a binary string, count number of substrings that start and end with 1.
- Repeat substrings of the given String required number of times
- Sum of all substrings of a string representing a number | Set 2 (Constant Extra Space)
- Minimum number of substrings the given string can be splitted into that satisfy the given conditions
- Number of Positions to partition the string such that atleast m characters with same frequency are present in each substring
- Find the longest sub-string which is prefix, suffix and also present inside the string | Set 2
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.