Java Solution with Explanation (beats 100% of submissions)
we will keep track of last index in s from which we started comparing with pattern if we encounter a * ( first we will consider * as 0 length )\nIf we encounter
we will keep track of last index in s from which we started comparing with pattern if we encounter a * ( first we will consider * as 0 length )\nIf we encounter a mismatch , then we will increase the last index(which means we are now considering 1 length in * ) \nSimilarly we will continue until we reach the end of string .\n```\nclass Solution {\n    public boolean isMatch(String s, String p) {\n        int i=0;\n        int j=0;\n        int starIdx=-1;\n        int lastMatch=-1;\n        \n        while(i<s.length()){\n            if(j<p.length() && (s.charAt(i)==p.charAt(j) || \n              p.charAt(j)==\'?\')){\n                i++;\n                j++;\n            }else if(j<p.length() && p.charAt(j)==\'*\'){\n                starIdx=j;\n                lastMatch=i;\n                j++;\n            }else if(starIdx!=-1){\n            //there is a no match and there was a previous star, we will reset the j to indx after star_index\n            //lastMatch will tell from which index we start comparing the string if we encounter * in pattern\n                j=starIdx+1;\n                lastMatch++; // we are saying we included more characters in * so we incremented the index \n                i=lastMatch;\n                \n            }else{\n                return false;\n            }\n        }\n        \n        while(j<p.length() && p.charAt(j)==\'*\') j++;\n        \n        if(i!=s.length() || j!=p.length()) return false;\n        \n        return true;\n     \n    }\n}\n```
['Greedy', 'Java']