Save 25%Black Friday: 25% off all plans — use code BLACKFRIDAY2026 at checkout. Ends Friday, Dec 4.Claim the deal

From an anonymous candidate: You are more recommended to use two pointers instead of dynamic programming to solve this problem during the interview

(This qustion is a variation of a LeetCode question 44. Wildcard Matching.)

Given an input string s and a pattern p, implement wildcard pattern matching with support for '*' where:

  • '*' Matches any sequence of characters (including the empty sequence).
  • The matching should cover the entire input string (not partial).

Constraints:

  • 0 <= s.length, p.length <= 2000
  • s contains only lowercase English letters.
  • p contains only lowercase English letters and '*' characters.
Test Cases
Input
Output
Expected