Problem
You get two strings s1 and s2. Return true if s2 contains a permutation of s1 as a substring. Return false if it does not.
A permutation of a string contains the same characters in any order. For example, "bca" is a permutation of "abc". A substring is a part of the string with consecutive characters.
Example 1
- Input:
- s1 = "tea", s2 = "bleatz"
- Output:
- true
- Explanation:
- The substring
"eat"starts at index 2. It is a permutation of"tea".
Example 2
- Input:
- s1 = "tea", s2 = "taste"
- Output:
- false
- Explanation:
- No substring of
"taste"with three characters contains onet, oneeand onea.
Example 3
- Input:
- s1 = "xyz", s2 = "xy"
- Output:
- false
- Explanation:
- The string
s2is shorter thans1.
Constraints
- 1 <= s1.length, s2.length <= 10^4
- s1 and s2 contain only lowercase English letters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Find All Anagrams in a String
Coding · Hash Table · Sliding Window · String
- Longest Repeating Character Replacement
Coding · Hash Table · Sliding Window · String
- Longest Substring with At Most K Distinct Characters
Coding · Hash Table · Sliding Window · String
- Longest Substring Without Repeating Characters
Coding · Hash Table · Sliding Window · String
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
Apple
Leetcode 567. Permutation in String
Reported Mar 13, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 1 record
Meta
Permutation in String
Reported date not specified · Source window: 3mo
Source snapshot: Oct 20, 2026
Source frequency score: 63.9. This is not an interview probability.
View source