[Python][DP] Inspired by kadane algo and buy sell stock IV
I. Intuition:\nThe key idea is that we find the maximum tiles can be covered with one carpet (at a time).\n\nFor the example:\nfloor = "10110101"\nnumCarpets=2\
I. Intuition:\nThe key idea is that we find the maximum tiles can be covered with one carpet (at a time).\n\nFor the example:\n`floor = "10110101"`\n`numCarpets=2`\n`carpetLen=2`\n\nWith numCapets = 2, that means we will have 2 carpets to use. \nFirst, we find the maximum tiles that the first carpet can cover.\n`dp[first_carpet] = [0, 1, 1, 1, 2, 2, 2, 2, 2]`\nWe can say that at the end of 9th floor, with one carpet, we can cover at most 2 tiles. Now we store the maximum tiles can be covered with one carpet in `prev_state`\nSecond, we now need to find the maxmimum tiles that the second carpet can cover. Then we take the sum of max tiles that the first carpet cover with the max tiles that the second carpet can cover. \n`dp[second_carpet] = [0, 1, 1, 2, 3, 3, 3, 3, 3]`\n\nII. Resources:\nhttps://leetcode.com/problems/best-time-to-buy-and-sell-stock-iv/solution/627971\n\nIII. Code:\n```\nclass Solution:\n    def minimumWhiteTiles(self, floor: str, numCarpets: int, carpetLen: int) -> int:\n \n        updated_floor = [0]*(len(floor)+1)\n        running = 0\n        for index, tiles in enumerate(floor):\n            if tiles == \'1\':\n                running += 1\n            updated_floor[index+1] = running\n  \n        prev_state = [0]*(len(floor)+1)\n        for i in range(numCarpets):\n            dp = [0]*(len(floor)+1)\n            for j in range(len(dp)-1):\n                if floor[j] == \'1\':\n                    \n                    dp[j+1] = max(prev_state[j+1], prev_state[max(j+1-carpetLen, 0)] + updated_floor[j+1]-updated_floor[max(j+1-carpetLen, 0)], dp[j])\n                    \n                else:\n                    dp[j+1] = max(prev_state[j+1], dp[j])\n                    \n            prev_state = dp\n   \n        return updated_floor[-1] - dp[-1]\n```
['Dynamic Programming', 'Python']