Class Solution
-
- All Implemented Interfaces:
public final class Solution3407 - Substring Matching Pattern.
Easy
You are given a string
sand a pattern stringp, wherepcontains exactly one'*'character.The
'*'inpcan be replaced with any sequence of zero or more characters.Return
trueifpcan be made a substring ofs, andfalseotherwise.A substring is a contiguous non-empty sequence of characters within a string.
Example 1:
Input: s = "leetcode", p = "ee\*e"
Output: true
Explanation:
By replacing the
'*'with"tcod", the substring"eetcode"matches the pattern.Example 2:
Input: s = "car", p = "c\*v"
Output: false
Explanation:
There is no substring matching the pattern.
Example 3:
Input: s = "luck", p = "u\*"
Output: true
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'*'
-
-
Constructor Summary
Constructors Constructor Description Solution()
-