Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Wildcard Matching

XPChallenge Points: 30
levelLevel: Hard

Write a function to check if a string s matches a pattern p where:
• ? matches any single character.
• * matches any sequence of characters, including an empty sequence.
The pattern must match the entire string, not just part of it.

Example 1:

Input: s = "hello", p = "h*o"

Output: true

Explanation:

* can match "ell".

Example 2:

Input: s = "code", p = "c*d?"

Output: false

Explanation:

The pattern expects one more character after d.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result