#27AI Log Wildcard Matching
An AI-powered server monitoring system analyzes log messages to identify important events such as errors, warnings, and system failures. Each log message is represented by a string s, and the monitoring rule is represented by a pattern p.
The pattern contains: A lowercase letter → matches the same character. ? → matches exactly one arbitrary character.
- → matches any sequence of characters, including an empty sequence.
The pattern must match the entire log message. Return true if the log message matches the monitoring rule; otherwise, return false.
Examples
Example 1
Input: s = "error"
p = "e*"
Output: true
Explanation: Here, e matches the first character and * matches "rror".
Example 2
Input: s = "warn"
p = "w??n"
Output: true
Explanation: Each ? matches one character: a and r.
Example 3
Input: s = "fail"
p = "f*x"
Output: false
Explanation: The pattern requires the complete message to end with x, but the message ends with l.
Constraints
- 0 ≤ s.length ≤ 2000
- 0 ≤ p.length ≤ 2000
- s contains only lowercase English letters.
- p contains lowercase English letters, ?, and *.
- Matching is case-sensitive.
- The entire string s must match the entire pattern p.
