Count Substrings That Differ by One Character LeetCode solution in Python

1
class Solution:
2
def countSubstrings(self, s: str, t: str) -> int:
3
res = 0
4
for i in range(len(s)):
5
for j in range(len(t)):
6
miss, pos = 0, 0
7
while i + pos < len(s) and j + pos < len(t) and miss < 2:
8
miss += s[i + pos] != t[j + pos]
9
res += miss == 1
10
pos += 1
11
return res

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0