Permutation in String

MediumSliding Window
Next
StringSliding WindowHash Map

Decide whether the second string contains a substring that is a permutation (any rearrangement) of the first string.

Input

Line 1: the string s1. Line 2: the string s2. Both contain lowercase letters.

Output

Print true if some substring of s2 is a permutation of s1, otherwise false.

Constraints

1 <= length of s1, s2 <= 10^4

Example 1
Input
ab
eidbaooo
Output
true

The substring ba is a permutation of ab.

Example 2
Input
ab
eidboaoo
Output
false

No window of two letters contains both a and b.

Hints

Permutation in String - Medium Sliding Window Problem | Skill Shiksha