vicejuniordev
Senior Member
Python:
class Solution:
def checkInclusion(self, s1: str, s2: str) -> bool:
d = Counter(s1)
n = len(s2)
l = 0
found = len(s1)
for r in range(n):
if s2[r] in d and d[s2[r]] > 0:
d[s2[r]] -= 1
found -= 1
if found == 0:
return True
else:
while s2[l] != s2[r]:
if s2[l] in d:
d[s2[l]] += 1
found += 1
l += 1
l += 1
return False
