class Solution:
def checkInclusion(self, s1: str, s2: str) -> bool:
target = Counter(list(s1))
visited = defaultdict(int)
left = 0
right = 0
valid = 0
while right < len(s2):
char = s2[right]
right += 1
if char in target:
visited[char] += 1
if visited[char] == target[char]:
valid += 1
while right - left >= len(s1):
if valid == len(target):
return True
char = s2[left]
left += 1
if char in target:
if visited[char] == target[char]:
valid -= 1
visited[char] -= 1
return False