✔️ 100% Fastest Swift Solution
\nclass Solution {\n    func isMatch(_ s: String, _ p: String) -> Bool {\n        var regular = ""\n        var last: Character = " "\n        \n        for c i
```\nclass Solution {\n    func isMatch(_ s: String, _ p: String) -> Bool {\n        var regular = ""\n        var last: Character = " "\n        \n        for c in p {\n            if c == "?" {\n                regular += "."\n            } else if c == "*" && last != "*" {\n                regular += ".*"\n            } else {\n                regular += String(c)\n            }\n            last = c\n        }\n        return regularExpressionMatching(s, regular)\n    }\n\n\n    func regularExpressionMatching(_ s: String, _ p: String) -> Bool {\n        var string = Array(s)\n        var chars: [Character] = []\n        var marks : [Bool] = []\n        var isMark: Bool = false\n        var list = [[-1, -1, 1]] // [start, end, is need to add next start]\n        var max = Int.min\n\n\n        func nextRange(_ list: [[Int]], _ char: Character, _ mark: Bool) -> [[Int]] {\n            var res = Set<[Int]>()\n            for range in list {\n                let lower = range[0] + range[2]\n                let upper = range[1] + 1\n                for i in lower...upper {\n                    if mark {\n                        var j = i\n                        var count = 0\n                        while j < string.count {\n                            if char == string[j] || char == "." {\n                                j += 1\n                                count += 1\n                            } else {\n                                break\n                            }\n                        }\n                        j = i + (count > 0 ? count - 1 : 0) \n                        if count > 0 {\n                            res.insert([i, j, 0])\n                        } else {\n                            res.insert(range)\n                        }\n                    } else {\n                        if i < string.count && (char == string[i] || char == ".") {\n                            res.insert([i, i, 1])\n                        }\n                    }\n                }\n            }\n\n            return Array(res)\n        }\n\n        for (_, c) in p.enumerated().reversed() {\n            if c == "*" {\n                isMark = true\n            } else {\n                chars.insert(c, at: 0)\n                marks.insert(isMark, at: 0)\n                isMark = false\n            }\n        }\n\n        for (index, c) in chars.enumerated() {\n            let mark = marks[index]\n            list = nextRange(list, c, mark)\n        }\n        for rang in list { max = max > rang[1] ? max : rang[1] }        \n        return max == string.count - 1\n    }\n\n}\n```\n\nLet me know in comments if you have any doubts. I will be happy to answer.\n\nPlease upvote if you found the solution useful.
['Swift']