[c++] Simple recursive + memoization | Easy to think | Commented
\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int minCover(string& s, int index, int numCarpets, int len){\n        if(index >= s.length())     
```\nclass Solution {\npublic:\n    vector<vector<int>> dp;\n    int minCover(string& s, int index, int numCarpets, int len){\n        if(index >= s.length())     // if index >= s.length(), then there is no tiles present.\n            return 0;\n        if(dp[index][numCarpets] != -1)     // State of the dp is represented by current index and no of Carpets remaining\n            return dp[index][numCarpets];\n        int res1 = INT_MAX;\n        if(numCarpets > 0)\n            res1 = minCover(s, index + len, numCarpets-1, len);     // If carpet is still remaining, we can try covering tiles in the range [index, index + len - 1]\n        int res2 = minCover(s, index+1, numCarpets, len);       // finding min no of white tiles visible if we doesn\'t cover the tile on this particular index\n        if(s[index] == \'1\')                 // white tile present at index, so if we don\'t cover those tile, then add corresponding count to res2\n            res2++;\n        return dp[index][numCarpets] = min(res1, res2);   // finally we choose the minimum from the above two case\n    }\n    \n    int minimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n        dp.resize(floor.length(), vector<int>(numCarpets+1, -1));\n        return minCover(floor, 0, numCarpets, carpetLen);\n    }\n};\n```\n***If you find this helpful, please show some love in the form of upvote***
[]