Skip to content

Practice Substring Matching Pattern

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#3407
LeetCode Problem

Substring Matching Pattern

Problem Statement

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.

Source: Substring Matching Pattern on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leetcode", p = "ee*e"
Output
true

# Example 2

Input
s = "car", p = "c*v"
Output
false

# Example 3

Input
s = "luck", p = "u*"
Output
true

Constraints

1 <= s.length <= 50
1 <= p.length <= 50
s contains only lowercase English letters.
p contains only lowercase English letters and exactly one '*'

Related LeetCode Problems

Practice more problems similar to Substring Matching Pattern.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.