Top Down || C++ Solution || Well commented
\nclass Solution {\npublic:\n    int explore(int i,string &floor,int numCarpets, int &carpetLen, vector<vector<int>> &dp)\n    {\n        if(i==floor.length())\
```\nclass Solution {\npublic:\n    int explore(int i,string &floor,int numCarpets, int &carpetLen, vector<vector<int>> &dp)\n    {\n        if(i==floor.length())\n        {\n            return 0;\n        }\n        if(dp[i][numCarpets]!=-1)\n        {\n            return dp[i][numCarpets];\n        }\n        \n        int ans=0;\n        //Put carpet here only if you have 1 or more carpet left\n            if(i+carpetLen<=floor.length()&&numCarpets>0)\n            {\n                ans+=carpetLen+explore(i+carpetLen,floor,numCarpets-1,carpetLen,dp);\n            }\n            else if(numCarpets>0)\n            {      //When current index+ carpet length > floor.length\n                 ans+=floor.length()-i;\n            }\n        \n        \n        //Dont put carpert here\n        if(floor[i]==\'0\')\n        {   //If current carpet is black\n            ans=max(ans,1+explore(i+1,floor,numCarpets,carpetLen,dp));\n        }\n        else\n        {\n            ans=max(ans,explore(i+1,floor,numCarpets,carpetLen,dp));\n        }\n        \n        return dp[i][numCarpets]=ans;\n    }\n    int minimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n        int n=floor.length();\n        //Store number of maximum black carpet from  index\n        vector<vector<int>> dp(n,vector<int>(numCarpets+1,-1));\n        //Explore will return maximum number of black carpet \n\t\t//we just subtract it from floor length to get \n\t\t//minimum number of white carpet\n        return n-explore(0,floor,numCarpets,carpetLen,dp);\n    }\n};\n```\n**Like it? Please Upvote ;-)**
['C', 'C++']