Skip to main content

🟡 剑指 Offer II 091. 粉刷房子

LeetCode 提示

题目难度 中等

原题链接 🔗 leetcode

题解 1.py#

class Solution:    def minCost(self, costs: List[List[int]]) -> int:        dfs = costs[0]        nhouse = len(costs)        for n in range(1, nhouse):            dfs = [                costs[n][0] + min(dfs[1], dfs[2]),                costs[n][1] + min(dfs[0], dfs[2]),                costs[n][2] + min(dfs[0], dfs[1]),            ]                return min(dfs)