Java | Top Down Dynamic Programming | Memoization
Solution:\n\nclass Solution {\n    Map<String, Integer> cache;\n    \n    public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n        c
Solution:\n```\nclass Solution {\n    Map<String, Integer> cache;\n    \n    public int minimumWhiteTiles(String floor, int numCarpets, int carpetLen) {\n        cache = new HashMap<>();\n        return helper(floor, 0, numCarpets, carpetLen);\n    }\n    \n    public int helper(String floor, int position, int numCarpets, int carpetLen) {\n        if (position >= floor.length()) {\n            return 0;\n        }\n        \n        if (floor.length() - position <= numCarpets * carpetLen) {\n            return 0;\n        }\n        \n        String key = position + ", " + numCarpets;\n        if (cache.containsKey(key)) {\n            return cache.get(key);\n        }\n        \n        if (numCarpets == 0) {\n            int output = floor.charAt(position) - \'0\' + helper(floor, position + 1, 0, carpetLen);\n            \n            cache.put(key, output);\n            return output;\n        }\n        \n        int output = Math.min(floor.charAt(position) - \'0\' + helper(floor, position + 1, numCarpets, carpetLen), helper(floor, position + carpetLen, numCarpets - 1, carpetLen));\n        \n        cache.put(key, output);\n        return output;\n    }\n}\n```
['Dynamic Programming', 'Memoization', 'Java']