FunctionRacerProblemsRace

Permutation in String

MediumTwo pointersPython, JavaScript, TypeScript, Java, C++

Return True if some contiguous piece of s2 uses exactly the same letters as s1 (in any order), otherwise False.

Example 1

s1 "ab"
s2 "eidbaooo"
returns true

ba appears in s2.

Example 2

s1 "ab"
s2 "eidboaoo"
returns false

ab and ba never sit together.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Two pointers problems