Sliding Window pattern

Permutation in String

Given two strings s1 and s2, return true if s2 contains a permutation of s1 as a contiguous substring (a window of length |s1| whose character counts match s1). Watch it run step by step, then write your own pseudocode and get it checked by AI.

  • LeetCode 567
  • Medium
  • 1 approach

Sign in with Google or GitHub and you land straight on this page. DSA comes with the all labs plan and every ChaiCode batch.

Sliding WindowLeetCode 567

Medium

The approach

  1. 01 Fixed-size window · frequency match O(|s1| + |s2|)O(1) space
Played step by step, with its time and space.

What you will learn

  • How to read Permutation in String and spot the sliding window pattern in it
  • Fixed-size window · frequency match: O(|s1| + |s2|) time, O(1) space
  • The pseudocode for each approach, its line lit as the animation runs
  • Practice: write your own pseudocode and get it checked

More Sliding Window

See Permutation in String run, step by step

Sign in and this page opens on the animation, with all 8 Sliding Window problems beside it.

DSA comes with the all labs plan and every ChaiCode batch.