Java recursive solution
```\npublic class Solution {\n    public boolean isMatch(String s, String p) {\n        return helper(s.toCharArray(), p.toCharArray(), 0, 0, 0, -1);\n    }\n  
```\npublic class Solution {\n    public boolean isMatch(String s, String p) {\n        return helper(s.toCharArray(), p.toCharArray(), 0, 0, 0, -1);\n    }\n    \n    private boolean helper(char[] s, char[] p, int i, int j, int lastS, int lastP) {\n        if(i == s.length && j == p.length) return true;\n        if(j < p.length) {\n            if(i == s.length)\n                return p[j] == '*' ? helper(s, p, i, j + 1, lastS, lastP) : false;\n            if(p[j] == '?' || s[i] == p[j])\n                return helper(s, p, i + 1, j + 1, lastS, lastP);\n            if(p[j] == '*')\n                return helper(s, p, i, j + 1, i, j);\n        }\n        if(lastP != -1) return helper(s, p, lastS + 1, lastP, lastS + 1, lastP);\n        return false;\n    }\n}
[]