3407. Substring Matching Pattern
3407. Substring Matching Pattern
Description
You are given a string s and a pattern string p, where p contains exactly one '*' character.
The '*' in p can be replaced with any sequence of zero or more characters.
Return true if p can be made a substring of s, and false otherwise.
Example 1:
1 | Input: s = "leetcode", p = "ee*e" |
Explanation:
By replacing the '*' with "tcod", the substring "eetcode" matches the pattern.
Example 2:
1 | Input: s = "car", p = "c*v" |
Explanation:
There is no substring matching the pattern.
Example 3:
1 | Input: s = "luck", p = "u*" |
Explanation:
The substrings "u", "uc", and "uck" match the pattern.
Constraints:
1 <= s.length <= 501 <= p.length <= 50scontains only lowercase English letters.pcontains only lowercase English letters and exactly one'*'
Hints/Notes
- 2025/01/12
- string
- 0x3Fâs solution(checked)
- Biweekly Contest 147
Solution
Language: C++
1 | class Solution { |