Dashboard
LC #567

Permutation in String

Pattern · ?AmazonGoogleMetaBloomberg

Problem

Given strings s1 and s2, return true if s2 contains a permutation of s1.

Constraints

  • 1 ≤ s1.length, s2.length ≤ 10⁴
  • s1 and s2 consist of lowercase English letters only

Example

Input
s1 = "ab", s2 = "eidbaooo"
Output
true
Why
s2 contains "ba" at index 3–4, which is a permutation of "ab"

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗