256. Paint House

Problem

Paint n houses with 3 colors so no two adjacent houses have the same color. Find the minimum cost.

There are n houses to be painted. Each house can be painted with one of 3 colors: Red, Blue, or Green. The cost of painting each house with each color is given in a 2D array costs where costs[i][j] is the cost of painting house i with color j.

No two adjacent houses can have the same color. Find the minimum cost to paint all houses.

Examples
Input: [[17,2,17],[16,16,5],[14,3,19]]
Output: 10
Hints
Related Problems

256. Paint House

Paint n houses with 3 colors so no two adjacent houses have the same color. Find the minimum cost.