← Visualizers
Sliding Window — Frequency LeetCode 567

Permutation in String / visualized

Does s2 contain any permutation of s1? A permutation is just a rearrangement — so it's a window of length s1.length whose character frequencies exactly match s1's. Slide a fixed window across s2, comparing counts.

Execution

idle
need (from s1)  vs  window (current)
Press Run to begin.
0 / 0
Speed

Java · running line

window need mismatch match found
O(n) time · O(1) space (26 letters)  ·  the window size is fixed at s1.length — this is a fixed window that happens to compare frequency tables.