Swift; first time doing DP problem
Looked up the technique; 221. Maximal Square has a good explanation in the solution.\n\nVery understandable! Far more enjoyable than other problems, and easier 
Looked up the technique; `221. Maximal Square` has a good explanation in the solution.\n\nVery understandable! Far more enjoyable than other problems, and easier I think. Will have to do more Dynamic Programming.\n\nBasic idea is that for each `[i][j]`, you need to look at the 3 adjacent squares you\'ve previously visited. Accumuluate your results as you go.\n\nTime Complexity: O(n*m)\n\n```\nclass Solution {\n    func countSquares(_ matrix: [[Int]]) -> Int {\n        var subsquares = 0\n        var dp = Array(repeating:Array(repeating: 0, count: matrix[0].count), count: matrix.count)\n        \n        for i in 0..<matrix.count {\n            for j in 0..<matrix[0].count {\n                let value = matrix[i][j]\n                guard value > 0 else { dp[i][j] = 0; continue }\n                let west      = (i == 0)           ? 0 : dp[i-1][j-0]\n                let northwest = (i == 0 || j == 0) ? 0 : dp[i-1][j-1]\n                let north     = (j == 0)           ? 0 : dp[i-0][j-1]\n                dp[i][j] = [west, northwest, north].min()! + value\n                subsquares += dp[i][j]\n            }\n        }\n        return subsquares\n    }\n}\n```
[]