Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Permutation in String

XPChallenge Points: 20
levelLevel: Medium

You are given two strings s1 and s2.
Determine whether any permutation (rearrangement) of s1 exists as a substring within s2.

Return true if s2 contains at least one substring that is a permutation of s1, and false otherwise.

Example 1:

Input: s1 = "ab", s2 = "eidbaooo"

Output: true

Explanation:

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

Example 2:

Input: s1 = "abc", s2 = "ccccbbbbaaaa"

Output: false

Explanation:

s2 does not contain any permutation of s1.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result