58. Permutation in String
Medium
Given the strings padrao and texto, determine whether any contiguous substring of texto is a permutation of padrao. Return a boolean. Assume the strings use lowercase letters a to z.
Example 1
Input: padrao = "abc", texto = "zzcabx"
Output: true
Explanation: The substring "cab" contains the same letters as the pattern.
Example 2
Input: padrao = "ab", texto = "aab"
Output: true
Constraints
- 1 <= padrao.length <= 10^4
- 0 <= texto.length <= 10^5
- The strings contain only lowercase ASCII letters.
StringsHash mapSliding window
Saved in this browser
Caso 1
padrao =
"abc"
texto =
"zzcabx"
Expected =
true
Caso 2
padrao =
"ab"
texto =
"aab"
Expected =
true
Run checks these 2 cases. Submit runs all 6, including hidden ones.