✔️ 100% Fastest Swift Solution
\nclass Solution {\n    func uniquePathsWithObstacles(_ obstacleGrid: [[Int]]) -> Int {\n        var matrix: [[Int]] = Array(repeating: Array(repeating: 0, coun
```\nclass Solution {\n    func uniquePathsWithObstacles(_ obstacleGrid: [[Int]]) -> Int {\n        var matrix: [[Int]] = Array(repeating: Array(repeating: 0, count: obstacleGrid[0].count), count: obstacleGrid.count)\n        \n        matrix[0][0] = 1\n        for i in 0..<obstacleGrid.count {\n            for j in 0..<obstacleGrid[0].count {\n                if i > 0 { matrix[i][j] += matrix[i - 1][j] }\n                if j > 0 { matrix[i][j] += matrix[i][j - 1] }\n                if obstacleGrid[i][j] == 1 { matrix[i][j] = 0 }\n            }\n        }\n        \n        return matrix[obstacleGrid.count - 1][obstacleGrid[0].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']