A builder wants to build a row of n houses that can be of k different colors. No two neighboring houses can be the same color. Given an n by k matrix where entry [i][j] is the cost to build house i with color j, return the minimum cost. Input: first line n and k, then n lines each with k costs. Output: minimum cost.
Example 1:
Example 2:
Constraints:
1 <= n <= 100 1 <= k <= 100 1 <= cost <= 10^4
Tags:
