Suppose we have two strings s and t, we have to find the minimum amount of operations required for s to make t a substring of s. Now, in each operation, we can choose any position in s and change the character at that position to any other character.
So, if the input is like s = "abbpqr", t = "bbxy", then the output will be 2, as we can take the substring "bbpq" and change 'p' to 'x' and 'q' to 'y'.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
class Solution: def solve(self, s, t): k, n = len(t), len(s) ans = 10**10 for i in range(n - k + 1): ss = s[i:i+k] ans = min(ans, sum(ss[j]!=t[j] for j in range(k))) return ans ob = Solution() print(ob.solve("abbpqr", "bbxy"))