房屋染色

来源:互联网 发布:ipad淘宝我的店铺在哪 编辑:程序博客网 时间:2024/04/25 01:49


class Solution:    # @param {int[][]} costs n x 3 cost matrix    # @return {int} an integer, the minimum cost to paint all houses    def minCost(self, costs):        # Write your code here        if len(costs) == 0:            return 0                record = costs[0]                for cost in costs[1:]:            temp = []            for i in range(len(cost)):                temp.append(cost[i]+min(record[i-1],record[i-2]))            record = temp                return min(record)


0 0
原创粉丝点击