Description
Given two strings s1 and s2, return true if s2 contains any permutation of s1. A permutation uses the same characters with the same frequency.
Examples
Input:
s1 = "ab", s2 = "eidbaooo"Output:
trueExplanation:
s2 contains 'ba' which is a permutation of s1.
Input:
s1 = "ab", s2 = "eidboaoo"Output:
falseExplanation:
Given s1 = "ab", s2 = "eidboaoo", the condition does not hold: s2 contains a permutation of s1.
Input:
s1 = "adc", s2 = "dcda"Output:
trueExplanation:
s2 contains 'dca' which is a permutation of s1. The characters 'd', 'c', and 'a' appear exactly once each in both strings, just in different order.
Constraints
- •
1 ≤ s1.length, s2.length ≤ 10⁴ - •
s1 and s2 consist of lowercase English letters.