[Java/C++/Python] DP solution
Explanation\ndp[i][k] means that,\nusing k tiles to cover the first i tiles\nthe minimum number of white tiles still visible.\n\n\nFor each tile s[i], we heve t
# **Explanation**\n`dp[i][k]` means that,\nusing `k` tiles to cover the first `i` tiles\nthe minimum number of white tiles still visible.\n\n\nFor each tile `s[i]`, we heve two options,\nOne option is doing nothing, `jump` this tile,\n`jump = dp[i - 1][k] + int(s[i - 1])`\nThe other option is covering this tile\n`cover = dp[i - l][k - 1]`\n\nThen we take the minimum result of two options:\n`dp[i][k] = min(jump, cover)`\n\nFinally after explore all combination of `(i,k)`,\nwe return `dp[n][nc]`.\n<br>\n\n# **Complexity**\nTime `O(NC)`\nSpace `O(NC)`\nwhere `N = floor.length` and `C = numCarpets`.\nSpace can be optimized to `O(N)`.\n<br>\n\n**Java**\n```java\n    public int minimumWhiteTiles(String s, int nc, int l) {\n        int n = s.length(), dp[][] = new int[n + 1][nc + 1];\n        for (int i = 1; i <= n; ++i) {\n            for (int k = 0; k <= nc; ++k) {\n                int jump = dp[i - 1][k] + s.charAt(i - 1) - \'0\';\n                int cover = k > 0 ? dp[Math.max(i - l, 0)][k - 1] : 1000;\n                dp[i][k] = Math.min(cover, jump);\n            }\n        }\n        return dp[n][nc];\n    }\n```\n\n**C++**\n```cpp\n    int minimumWhiteTiles(string s, int nc, int l) {\n        int n = s.size();\n        vector<vector<int>> dp(n + 1, vector<int>(nc + 1));\n        for (int i = 1; i <= n; ++i) {\n            for (int k = 0; k <= nc; ++k) {\n                int jump = dp[i - 1][k] + s[i - 1] - \'0\';\n                int cover = k > 0 ? dp[max(i - l, 0)][k - 1] : 1000;\n                dp[i][k] = min(cover, jump);\n            }\n        }\n        return dp[n][nc];\n    }\n```\n\n**Python3**\n```py\n    def minimumWhiteTiles(self, A, k, l):\n\n        @lru_cache(None)\n        def dp(i, k):\n            if i <= 0: return 0\n            return min(int(A[i - 1]) + dp(i - 1, k), dp(i - l, k - 1) if k else 1000)\n            \n        return dp(len(A), k) \n```\n
['C', 'Python', 'Java']