Swift: Wildcard Matching (+ Test Cases)
swift\nclass Solution {\n    func isMatch(_ s: String, _ p: String) -> Bool {\n        let sArr = Array(s), pArr = Array(p)\n        let pBools = [Bool](repeati
```swift\nclass Solution {\n    func isMatch(_ s: String, _ p: String) -> Bool {\n        let sArr = Array(s), pArr = Array(p)\n        let pBools = [Bool](repeating: false, count: p.count + 1)\n        var dp = Array(repeating: pBools, count: s.count + 1)\n        dp[0][0] = true\n        (0...s.count).forEach {\n            for j in 0...p.count where j > 0 {\n                let cp = pArr[j-1]\n                if cp != "*" {\n                    dp[$0][j] = $0 > 0 && dp[$0-1][j-1] && (cp == sArr[$0-1] || cp == "?")\n                } else {\n                    var flag = false\n                    for k in 0...$0 where dp[k][j-1] {\n                        flag = true\n                    }\n                    dp[$0][j] = flag || j == 1\n                }\n            }\n        }\n        return dp[s.count][p.count]\n    }\n}\n```\n\n```swift\nimport XCTest\n\n// Executed 5 tests, with 0 failures (0 unexpected) in 0.045 (0.047) seconds\n\nclass Tests: XCTestCase {\n    private let s = Solution()\n    func test0() {\n        let res = s.isMatch("aa","a")\n        XCTAssertEqual(res, false)\n    }\n    func test1() {\n        let res = s.isMatch("aa","*")\n        XCTAssertEqual(res, true)\n    }\n    func test2() {\n        let res = s.isMatch("cb","?a")\n        XCTAssertEqual(res, false)\n    }\n    func test3() {\n        let res = s.isMatch("adceb","*a*b")\n        XCTAssertEqual(res, true)\n    }\n    func test4() {\n        let res = s.isMatch("acdcb","a*c?b")\n        XCTAssertEqual(res, false)\n    }\n}\n\nTests.defaultTestSuite.run()\n```
['Swift']