Sliding Window
LC #567Medium
Permutation in String
Sliding Window
AmazonGoogleMetaBloombergProblem
Given strings s1 and s2, return true if s2 contains a permutation of s1.
stringsliding-windowhash-map
Constraints
- ›1 ≤ s1.length, s2.length ≤ 10⁴
- ›s1 and s2 consist of lowercase English letters only
Example
Input
s1 = "ab", s2 = "eidbaooo"Output
trueWhy
s2 contains "ba" at index 3–4, which is a permutation of "ab"