Easy intuitive Solution Using Recursion and Memoization
Intuition\nwe will try to put carpet on every white tile where it exists till\nour number of carpets are over.\n\n# Approach\nif we find a white tile we will pu
# Intuition\nwe will try to put carpet on every white tile where it exists till\nour number of carpets are over.\n\n# Approach\nif we find a white tile we will put a carpet based on the length of\nthe carpet and look for more white tile and put carpet over them too,\nif the number of carpet is over we cant do anything at that case we \nhave to count the white tiles. If it is black tile we ignore it.\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumWhiteTiles(string floor, int numCarpets, int carpetLen) {\n        vector<vector<int>>dp(floor.size(),vector<int>(numCarpets+1,-1));\n        return solve(0,floor,numCarpets,carpetLen,dp);\n    }\n    int solve(int i,string &floor, int numCarpets, int &carpetLen,vector<vector<int>>&dp){\n        if(i == floor.size()) return 0;\n        if(dp[i][numCarpets] != -1) return dp[i][numCarpets];\n\n        if(floor[i] == \'1\'){\n            int putCarpet=INT_MAX;\n            if(numCarpets!=0) \n            {\n               int temp= floor.size();\n                putCarpet = solve( min(temp,i+carpetLen),floor,numCarpets-1,carpetLen,dp);\n            }\n\n            int notput=1+solve(i+1,floor,numCarpets,carpetLen,dp);\n\n            return dp[i][numCarpets] = min(putCarpet,notput);\n\n        }else{\n            //ignore black tiles\n            return dp[i][numCarpets] =solve(i+1,floor,numCarpets,carpetLen,dp);\n        }\n    }\n};\n```
['Recursion', 'Memoization', 'C++']