Beats 100!! efficient js solution using dp
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nlet dp=Array.from({length:1001},()=>Array(1001).fill(0));\n/**\n * @param {string} floor\n * @param {number} numCarpets\n * @param {number} carpetLen\n * @return {number}\n */\n\nvar minimumWhiteTiles = function(floor, numCarpets, carpetLen) {\n\n    // let pfix=new Array(floor.length).fill(0);\n    // let cnt=0;\n    // pfix[0]=floor[0]==\'1\'?1:0;\n    // cnt+=floor[0]==\'1\'?1:0;\n    // for(let i=1;i<floor.length;i++){\n\n    //     pfix[i]=pfix[i-1]+(floor[i]==\'1\'?1:0);\n    //     cnt+= floor[i]==\'1\'?1:0;\n\n    //     // if(i-carpetLen>=0) pfix[i]-=pfix[i-carpetLen];\n        \n    // }\n    let all=0;sum=0;\n    for(let i=0;i<floor.length;++i){\n        all+=floor.charCodeAt(i) & 1;\n        sum+=floor.charCodeAt(i) & 1;\n        if(i>=carpetLen) sum-=floor.charCodeAt(i-carpetLen) & 1;\n        for(let j=0;j<=numCarpets;++j){\n            if(!j){\n                dp[i][j]=0; continue;\n            }\n            if(i<carpetLen){\n                // dp[i][j]=pfix[i]; continue;\n                dp[i][j]=sum; continue;\n\n            }\n            // dp[i][j]=Math.max(dp[i-1][j],dp[i-carpetLen][j-1]+sum);\n      dp[i][j] = Math.max(dp[i - 1][j], dp[i - carpetLen][j - 1] + (sum));\n\n        }\n\n    }\n    // return cnt - dp[floor.length -1][numCarpets];\n  return all - dp[floor.length - 1][numCarpets];\n\n// }\n    // console.log(dp)\n//     function solve(idx=0,num=0,prev=0,ones=0){\n//            if(num==numCarpets) {mx=Math.max(mx,ones); return mx;}\n//            if (idx>=floor.length){mx=Math.max(mx,(ones+(pfix[floor.length-1]-pfix[prev]))); return mx;}\n//         solve(idx+1,num,idx,ones);\n//         // include \n//         let newOnes=idx-carpetLen>=0?(ones+pfix[idx]-pfix[idx-carpetLen]):pfix[idx];\n//          solve(idx+carpetLen,num+1,idx,newOnes);\n//     }\n//     solve();\n//     return cnt-mx;\n// };\n// // dp[i][num]=>at the ith index denotes the most no.of ones covered at the ith index when it\'s covered with num number of carpets\n// let n = floor.length;\n// // let dp = Array.from({ length: 1001 }, () => new Uint32Array(1001));\n// let dp=Array.from({length:floor.length},()=>Array(numCarpets+1).fill(0));\n\n//   let all = 0;\n//   let sum = 0;\n//   for (let i = 0; i < n; i++) {\n//     all += floor.charCodeAt(i) & 1;\n//     sum += floor.charCodeAt(i) & 1;\n//     if (i >= carpetLen) sum -= floor.charCodeAt(i - carpetLen) & 1;\n\n//     for (let j = 0; j <= numCarpets; ++j) {\n//       if (!j) {\n//         dp[i][j] = 0;\n//         continue;\n//       }\n//       if (i < carpetLen) {\n//         dp[i][j] =(pfix[i]);\n//         continue;\n//       }\n    //   dp[i][j] = Math.max(dp[i - 1][j], dp[i - carpetLen][j - 1] + (pfix[i]-pfix[i-carpetLen]));\n//     }\n//   }\n\n//   return cnt - dp[floor.length - 1][numCarpets];\n}\n```
['JavaScript']