House painting minimum cost

Write codeMedium25 min

Your task

A row of houses must each be painted one of k colors. costs[i][j] is the cost to paint house i with color j. No two adjacent houses may share a color. Return the minimum total cost to paint all houses. costs has at least one color column when non-empty; it may be empty.

Examples

paint_house_k(costs: list[list[int]]) -> int
Example 1
Inputpaint_house_k([[1, 5, 3], [2, 9, 4]])
Output5