Skip to content
#

computer-science

Here are 1,936 public repositories matching this topic...

javascript-algorithms
leetcode
azl397985856
azl397985856 commented Feb 5, 2020

假如有一排房子,共 n 个,每个房子可以被粉刷成红色、蓝色或者绿色这三种颜色中的一种,你需要粉刷所有的房子并且使其相邻的两个房子颜色不能相同。

当然,因为市场上不同颜色油漆的价格不同,所以房子粉刷成不同颜色的花费成本也是不同的。每个房子粉刷成不同颜色的花费是以一个 n x 3 的矩阵来表示的。

例如,costs[0][0] 表示第 0 号房子粉刷成红色的成本花费;costs[1][2] 表示第 1 号房子粉刷成绿色的花费,以此类推。请你计算出粉刷完所有房子最少的花费成本。

注意:

所有花费均为正整数。

示例:

输入: [[17,2,17],[16,16,5],[14,3,19]]
输出: 10
解释: 将 0 号房子粉刷成蓝色,1 号房子粉刷成绿色,2 号房子粉刷成蓝色。
  最少花费: 2 + 5 + 3 = 10。

题目地址: ht

Mind-Expanding-Books

Improve this page

Add a description, image, and links to the computer-science topic page so that developers can more easily learn about it.

Curate this topic

Add this topic to your repo

To associate your repository with the computer-science topic, visit your repo's landing page and select "manage topics."

Learn more

You can’t perform that action at this time.