Given two strings S1 and S2 ( size of S1 <= Size of S2 ). The task is to find the minimum number of characters to be replaced in the string S2, such that the string S1 is a substring of S2.
Input : S1 = cdef, S2 = abbdef Output : 1 Input : S1 = gfg, S2 = fgg Output : 2
- Traverse the string S2
- From every index in S2, check the number of mis-matching characters in substring of length of S1
- Store and update the minimum of prev and current mis-match in ans
- Return ans.
Below is the implementation of the above approach:
Time Complexity: O(N * M).
- Minimum swaps required to make a binary string divisible by 2^k
- Minimum swaps required to make a binary string alternating
- Minimum operations required to make the string satisfy the given condition
- Minimum number of given operations required to convert a string to another string
- Operations required to make the string empty
- Minimum cuts required to convert a palindromic string to a different palindromic string
- Minimum rotations required to get the same String | Set-2
- Minimum rotations required to get the same string
- Minimum steps to remove substring 010 from a binary string
- Minimum splits in a binary string such that every substring is a power of 4 or 6.
- Minimum changes required such that the string satisfies the given condition
- Minimum given operations required to convert a given binary string to all 1's
- Minimum operations required to convert a binary string to all 0s or all 1s
- Minimum swaps required to convert one binary string to another
- Minimum steps to delete a string by deleting substring comprising of same characters
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.