Paint House
Problem Paint n houses each red, blue, or green given an n x 3 cost matrix, where costs[i][c] is the cost to paint house i colour c. No two adjacent houses may share a colour. Minimise the total painting cost.
Input / Output
- Input: int costs[n][3].
- Output: the minimum total cost.
Constraints
- n up to 100 (classic bounds); an O(n) solution with O(1) state is expected.
- Adjacent houses must differ in colour.
Example
- [[17,2,17],[16,16,5],[14,3,19]] → 10 (blue 2, green 5, blue 3).
asked …