✔ C++ | DP | Heavily Commented
\nclass Solution {\n    \nprivate:\n    int dp[1001][1001];\n    int suffix[1001];\npublic:\n    int recur(string &floor,int numCarpets,int carpetLen,int idx)\n
```\nclass Solution {\n    \nprivate:\n    int dp[1001][1001];\n    int suffix[1001];\npublic:\n    int recur(string &floor,int numCarpets,int carpetLen,int idx)\n    {\n        //Base Cases\n        if(idx>=floor.size())\n            return 0;\n    \n        if(numCarpets==0)\n            return suffix[idx];\n        \n        //Memoization\n        if(dp[idx][numCarpets]!=-1)\n            return dp[idx][numCarpets];\n        \n        //Check if current tile is white,\n        //We need to add 1 because we are skipping\n        int op1=(floor[idx]==\'1\')+recur(floor,numCarpets,carpetLen,idx+1);\n        //We are using one carpet and hence we jump directly \n        //by carpetLen moves\n        int op2=recur(floor,numCarpets-1,carpetLen,idx+carpetLen);\n        return dp[idx][numCarpets]=min(op1,op2);\n    }\n    int minimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n        \n       int n=floor.size();\n       memset(dp,-1,sizeof dp);\n        \n       /*We make a suffix array which will tell \n       us count of white tiles after current tile\n       (including current tile also), we need to do this step\n       else we will get TLE */\n       suffix[n - 1] = (floor[n - 1] == \'1\');\n        for (int i = n - 2; i >= 0; i--) {\n            suffix[i] = suffix[i + 1] + (floor[i] == \'1\');\n        }\n        return recur(floor,numCarpets,carpetLen,0);\n    }\n};\n```\n\n**Pls upvote the solution if you found helpful, it means a lot.\nAlso comment down your doubts.\nHappy Coding : )**
['Dynamic Programming', 'Memoization', 'C', 'C++']