229. Permutation in String

MediumStringString

Given strings s1 and s2, return true if s2 contains a permutation of s1 as a contiguous substring. Input: '"s1", "s2"'.

Input: '"s1", "s2"'.

Output: Boolean — true or false.

Examples

Example 1
Input: "ab", "eidbaooo"
Output: true
Explanation: 'ba' is a permutation of 'ab'.
Example 2
Input: "ab", "eidboaoo"
Output: false
Explanation: No permutation window.
Example 3
Input: "a", "a"
Output: true
Explanation: Exact match.

Constraints

Asked by

MicrosoftAmazonBloombergGoogleAdobeOracle
Solve this problem in the editor →