Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Permutation in String

Medium
sliding-windowstringhash-table

Given two strings s1 and s2, return true if s2 contains a permutation of s1 as a substring.

Input

  • Line 1: string s1
  • Line 2: string s2

Output: true or false.

Example 1
Input:
ab
eidbaooo
Output:
true

"ba" is a permutation of "ab".

Example 2
Input:
ab
eidboaoo
Output:
false

Constraints

  • 1 ≤ s1.length, s2.length ≤ 10^4
  • Lowercase English letters only.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.