Problem: Wildcard Matching

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

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

Example 1:

       Input: s = "aa", p = "a"
       Output: false
       Explanation: "a" does not match the entire string "aa".
       Example 2:

       Input: s = "aa", p = "*" 
       Output: true
       Explanation: '*' matches any sequence.

```class Solution { public boolean isMatch(String s, String p) { if (p == null || p.length() == 0) return (s == null | s.length() == 0);

    if (p == "*") return true;

    int ls = s.length(), lp = p.length();
    int i = 0, j = 0;
    int star = -1, match = 0;

    while (i < ls){

        if(j < lp && (s.charAt(i) == p.charAt(j) || p.charAt(j) == '?')){
            i++;
            j++;
        }else if (j < lp &&p.charAt(j) == '*'){
            star = j;
            match = i;
            j++;
        }else if (star != -1) {
            i = ++match;
            j = star+1;
        }
        else return false;
    }

    while (j < lp){
        if (p.charAt(j) != '*') return false;
        j++;
    }

    return j == lp;
}

} ```

Untitled-1.jpg

Untitled-2.jpg