567 Permutation in String
Input:s1 = "ab" s2 = "eidbaooo"
Output:True
Explanation: s2 contains one permutation of s1 ("ba").Input:s1= "ab" s2 = "eidboaoo"
Output: Falsedef checkInclusion(self, s1, s2):
"""
:type s1: str
:type s2: str
:rtype: bool
"""
sorted_s1 = sorted(s1)
go_till = len(s2) - len(s1) + 1
for i in range(0, go_till):
if sorted_s1 == sorted(s2[i:i+len(s1)]):
return True
return FalseLast updated