3684. Substring Matching Pattern
My accepted Python solution to LeetCode problem 3684, Substring Matching Pattern, running in 0ms.
- Difficulty: Easy
- Python
- Runtime 0ms
- Memory 17.2MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2026-01-01.
class Solution:
def hasMatch(self, s: str, p: str) -> bool:
parts = p.split('*')
prefix = parts[0]
suffix = parts[1]
# Find prefix starting position
start = s.find(prefix)
if start == -1:
return False
# Find suffix starting after prefix
suffix_start = s.find(suffix, start + len(prefix))
if suffix_start == -1:
return False
return True