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:bool isMatch(const char *s, const char *p)Some examples:isMatch("aa","a") → falseisMatch("aa","aa") → trueisMatch("aaa","aa") → falseisMatch("aa", "*") → trueisMatch("aa", "a*") → trueisMatch("ab", "?*") → trueisMatch("aab", "c*a*b") → false
1 public class Solution { 2 public boolean isMatch(String s, String p) { 3 int slen = s.length(), plen = p.length(); 4 int i =0, j =0; 5 int ss =0, starP =- 1; 6 while(i < slen){ 7 8 while( j < plen && p.charAt(j) == '*'){ 9 starP = j ;10 j++;11 ss = i;12 }13 14 if(j