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 splits in a binary string such that every substring is a power of 4 or 6.
- Minimum steps to remove substring 010 from a binary string
- Minimum changes required such that the string satisfies the given condition
- Minimum swaps required to convert one binary string to another
- Minimum number of subsequences required to convert one string to another
- Minimum operations required to convert a binary string to all 0s or all 1s
- Minimum given operations required to convert a given binary string to all 1's
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.