Permutations in String

Given strings *s1* and *s2*, return `true` if *s2* contains any permutation of *s1* as a substring. Otherwise, return `false`. (Sliding window + two-pointer with hash).

Input Format

Two lines: s1, then s2.

Output Format

"true" or "false".

Constraints

  • len(s1), len(s2) <= 10^4; lowercase letters.

Examples

Example 1:

Input:

s1 = "ab"
s2 = "eidbaooo"

Output:

true

Explanation:

"ba" is a permutation of "ab" and appears in s2.

Loading...
Permutations in String - Strings DSA Problem