Java Knapsack Solution
\nclass Solution {\n    int pref[];\n\n    public int minimumWhiteTiles(String floor, int tot, int len) {\n        char a[] = floor.toCharArray();\n        this
```\nclass Solution {\n    int pref[];\n\n    public int minimumWhiteTiles(String floor, int tot, int len) {\n        char a[] = floor.toCharArray();\n        this.pref = new int[a.length];\n        int c = 0;\n        this.dp = new int[a.length + 1][tot + 1];\n        for (int d[] : dp) Arrays.fill(d, -1);\n        for (int i = 0; i < a.length; i++) {\n            if (a[i] == \'1\') c++;\n            pref[i] = c;\n        }\n        return pref[a.length - 1] - solve(0, a, tot, len);  // total ones - max removed\n    }\n\n    int dp[][];\n\n    private int solve(int index, char a[], int tot, int len) {\n        if (index >= a.length || tot == 0) {\n            return 0;\n        }\n        if (dp[index][tot] != -1) return dp[index][tot];\n        int ones = pref[Math.min(index + len - 1, a.length - 1)] - (index == 0 ? 0 : pref[index - 1]);\n        int take = ones + solve(index + len, a, tot - 1, len);  // either take it and add one\'s count in that subsegment\n        int dont = solve(index + 1, a, tot, len);  // or dont \n        return dp[index][tot] = Math.max(take, dont);  // return max of both\n    }\n}\n```
['Memoization', 'Java']