Given two strings s1 and s2, return true if s2 contains a permutation of s1 as a contiguous substring — that is, one of s1's permutations is a substring of s2.
s1 = "ab", s2 = "eidbaooo"trues1 = "ab", s2 = "eidboaoo"falseSolve it in the editor. Sign in free to run your Python or JavaScript against test cases, get a verdict, and track your attempts.
Solve on FeatCode →A window — a contiguous subarray or substring — expands and shrinks as it moves across the input, so you track a running condition instead of recomputing it from scratch for every possible window.
Read the full Sliding Window guide →
Original problem on LeetCode ↗