You are given an even integer n representing the number of houses arranged in a row, along with a cost of dimensions n $ imes$ cost[i][j] represents the cost to paint house i with color j.
You must paint every house using one of the
No two adjacent houses have the same color. That is, house i and house i + 1 must be painted with different colors for all
Houses that are equidistant from the opposite ends cannot have the same color. That is, house i and house $n - 1 - i$ must be painted with different colors for all
Return the minimum total cost needed to paint all the houses.
Constraints:
n
n is even.
cost.length n
cost[i].length
cost[i][j]
You are given an even integer n representing the number of houses arranged in a row, along with a cost of dimensions n $ imes$ cost[i][j] represents the cost to paint house i with color j.
You must paint every house using one of the
No two adjacent houses have the same color. That is, house i and house i + 1 must be painted with different colors for all
Houses that are equidistant from the opposite ends cannot have the same color. That is, house i and house $n - 1 - i$ must be painted with different colors for all
Return the minimum total cost needed to paint all the houses.
Constraints:
n
n is even.
cost.length n
cost[i].length
cost[i][j]