1794. Count Pairs of Equal Substrings With Minimum Difference
Содержание
class Solution:
def countQuadruples(self, firstString: str, secondString: str) -> int:
last = {c: i for i, c in enumerate(secondString)}
res, mi = 0, inf
for i, c in enumerate(firstString):
if c in last:
t = i - last[c]
if mi > t:
mi = t
res = 1
elif mi == t:
res += 1
return res