class Solution:
def checkInclusion(self, s1: str, s2: str) -> bool:
n, num_total = len(s2), len(s1)
mapping = Counter(s1)
s_map, s_count = dict(), 0
res = []
left = right = 0
while right < n:
char = s2[right]
right += 1
if char not in mapping:
s_map.clear()
s_count = 0
left = right
else:
count = s_map.get(char, 0)
s_map[char] = count + 1
if count < mapping[char]:
s_count += 1
while right - left == num_total:
if s_count == num_total:
return True
char = s2[left]
left += 1
count = s_map.get(char, 0)
s_map[char] = count - 1
if count <= mapping[char]:
s_count -= 1
return False