Example
Input
s = 'oidbcaf', pattern = 'abc'
Output
True
The substring 'bca' (positions 3..5) is a permutation of 'abc'.
Full lesson preview
Determine if any permutation of a given pattern exists as a substring in the input string using a frequency map and sliding window.
Problem statement
Task
Examples
Input
s = 'oidbcaf', pattern = 'abc'
Output
True
The substring 'bca' (positions 3..5) is a permutation of 'abc'.
Input format
Output format
Constraints
Samples
Input
s = 'aaacb', pattern = 'abc'
Output
True
Substring 'acb' is a permutation of 'abc'.