C++ Simple and Clean Solution, Detailed Explanation
Idea:\nWe use two pointers: pi for p, and si for s.\nWe also keep variables: star for the index of the last *, and count for the substring we are matching for t
**Idea:**\nWe use two pointers: `pi` for `p`, and `si` for `s`.\nWe also keep variables: `star` for the index of the last `*`, and `count` for the substring we are matching for the `*`.\nThese are the cases:\n1. The pattern has a `*`: update `count` and `star`.\n2. The letters in both s and p are equal, or the pattern has a `?`: Match! just advance pointers.\n3. Otherwise, we try to append this letter to a substring matching a `*`.\n4. If there was no star - return false.\n\nIf we have more stars at the end of `p`, we skip them, and then if we reached the end of the pattern - return true.\n\n```\nclass Solution {\npublic:\n    bool isMatch(string s, string p) {\n        int pi = 0, si = 0, star = -1, count = 0;\n        \n        while (si < s.size()) {\n            \n            if (p[pi] == \'*\') {\n                count = si;\n                star = pi++;\n            }\n            \n            else if (p[pi] == s[si] || p[pi] == \'?\') {\n                pi++, si++;\n            }\n            \n            else if (star >= 0){\n                pi = star+1;\n                si = ++count;\n                \n            }\n            else return false;\n        }\n        \n        while (pi < p.size() && p[pi] == \'*\') pi++;\n        return pi == p.size();\n    }\n};\n```\n**Like it? please upvote!**
['C']