Medium

Quiz

#567 Permutation in String

APPROACH

Given strings s1 and s2, return true if any anagram (rearrangement) of s1 appears as a contiguous substring of s2, or false otherwise.

Example 1:

Input: s1 = "ab", s2 = "eidbaooo"
Output: true
Explanation: s2 contains one permutation of s1 ("ba").

Example 2:

Input: s1 = "ab", s2 = "eidboaoo"
Output: false
1 of 4
1:00

What is the optimal approach for this problem?