IT评测·应用市场-qidao123.com技术社区

标题: [LeetCode] 256. Paint House [打印本页]

作者: 西河刘卡车医    时间: 2022-8-10 09:04
标题: [LeetCode] 256. Paint House
There is a row of n houses, where each house can be painted one of three colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.
The cost of painting each house with a certain color is represented by an n x 3 cost matrix costs.
Return the minimum cost to paint all houses.
Example 1:
  1. Input: costs = [[17,2,17],[16,16,5],[14,3,19]]
  2. Output: 10
  3. Explanation: Paint house 0 into blue, paint house 1 into green, paint house 2 into blue.
  4. Minimum cost: 2 + 5 + 3 = 10.
复制代码
Example 2:
  1. Input: costs = [[7,6,2]]
  2. Output: 2
复制代码
Constraints:
<ul>costs.length == n
costs.length == 3
1




欢迎光临 IT评测·应用市场-qidao123.com技术社区 (https://dis.qidao123.com/) Powered by Discuz! X3.4