C++ | with comments | DP
dp[idx][rem] wil store  maximum tiles we can cover from idx to last index if we are at index idx with rem amount of carpet\n\n\nclass Solution {\npublic:\n    v
```dp[idx][rem]``` wil store  maximum tiles we can cover from ```idx to last index``` if we are at index ```idx``` with ```rem``` amount of carpet\n\n```\nclass Solution {\npublic:\n    vector<int>tile;\n    vector<vector<int>>dp;\n    int minimumWhiteTiles(string f, int num, int len) {\n        int sz=f.size(),totalWHiteTiles=0;\n        for(int i=0;i<sz;i++){\n            if(f[i]==\'1\')\n                totalWHiteTiles++;\n            tile.push_back(totalWHiteTiles);\n        }\n        dp.resize(sz,vector<int>(num+1,-1));\n        return totalWHiteTiles-helper(f,0,num,len);\n    }\n    int helper(string &floor,int idx,int rem,int &len){\n        if(idx>=floor.size() || rem==0)\n            return 0;\n        if(dp[idx][rem]!=-1)\n            return dp[idx][rem];\n        int sz=floor.size();\n        // don\'t start covering the tiles from here\n        int a=helper(floor,idx+1,rem,len);\n        // start covering the  tiles from here\n        int b=helper(floor,idx+len,rem-1,len);\n        // last index where the carpet can go if we start coering from here\n        int lastIdx=idx+len-1;\n        // calculating how many tiles we will civer if we start from here\n        b+=tile[lastIdx>=sz?(sz-1):lastIdx]-tile[idx];\n        if(floor[idx]==\'1\')\n            b++;\n        dp[idx][rem]=max(a,b);\n        return dp[idx][rem];\n    }\n};\n```\nDo **UPVOTE** if it helps :)
['C']