Regular Expression Match

Implement wildcard pattern matching with support for '?' and '*'.

  • '?' : Matches any single character.
  • '*' : Matches any sequence of characters (including the empty sequence).

The matching should cover the entire input string (not partial).

The function prototype should be:

int isMatch(const char *s, const char *p)

Examples :

isMatch("aa","a") → 0
isMatch("aa","aa") → 1
isMatch("aaa","aa") → 0
isMatch("aa", "*") → 1
isMatch("aa", "a*") → 1
isMatch("ab", "?*") → 1
isMatch("aab", "c*a*b") → 0

Return 1/0 for this problem.

Interview Code Editor
Hints
  • Solution Approach
  • Complete Solution
750 successful submissions.
Asked In:
  • Facebook
  • Microsoft
Click here to jump start your coding interview preparation