Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Sliding window

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Sliding window

Permutation in String

intermediatelayer B5 · Sliding window5 tests

Given two strings s1 and s2, return true if s2 contains some permutation of s1 as a contiguous substring, and false otherwise.

  • In other words: is there a window of s2 with exactly the same letter counts as s1?
  • An empty s1 is contained in anything, so return true
  • If s1 is longer than s2 the answer is false
  • Return an actual boolean, not a number

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen