Paint House
Problem statement
Paint a row of houses using three colors, numbered 0, 1, and 2. The value costs[i][color] is the cost of painting house i that color.
For this exercise, assume each house gets exactly one color and neighboring houses must have different colors. Return the smallest total cost.
Function
minPaintCost(costs: int[][]) → intExamples
Example 1
costs = [[17,2,17],[16,16,5],[14,3,19]]return = 10Choose colors [1,2,1]. The cost is 2 + 5 + 3 = 10. Neighboring colors differ, and no valid coloring costs less.
Example 2
costs = [[7,6,2]]return = 2There is one house, so choose color 2, which costs 2.
Constraints
1 <= costs.length <= 200costs[i].length == 30 <= costs[i][color] <= 10000