Determine whether a pattern string can be matched against a text string by comparing a fixed-length substring relationship.
You are given two strings: a text string s and a pattern string p.
Your task is to determine whether there exists a way to match p to some substring of s according to the problem's substring-matching rule. In the common interview formulation, this means checking whether p occurs in s as a contiguous substring or whether two strings can be aligned so that the pattern matches a substring of the text.
Return whether such a match exists.
s and p.Example 1
Input
s = "leetcode" p = "code"
Output
true
Explanation
The substring "code" appears contiguously inside "leetcode".
Example 2
Input
s = "hello" p = "world"
Output
false
Explanation
No contiguous substring of "hello" matches "world".
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.