Tap here to switch tabs
Problem
Submissions

Problem: Paint House

med
30 min
Try to solve the Paint House problem.

Statement

There is a row of nn houses, where each house can be painted in one of 33 colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

The cost of painting house i with a certain color is represented by an nimes3n imes 3 cost matrix costs. For example, costs[0][0] is the cost of painting house 00 with the color red, costs[1][2] is the cost of painting house 11 with the color green, and so on.

Return the minimum cost to paint all houses.

Constraints:

  • costs.length =n= n

  • costs[i].length =3= 3

  • 1≤n≤1001 \leq n \leq 100

  • 1≤1 \leq costs[i][j] ≤20\leq 20

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Paint House

med
30 min
Try to solve the Paint House problem.

Statement

There is a row of nn houses, where each house can be painted in one of 33 colors: red, blue, or green. The cost of painting each house with a certain color is different. You have to paint all the houses such that no two adjacent houses have the same color.

The cost of painting house i with a certain color is represented by an nimes3n imes 3 cost matrix costs. For example, costs[0][0] is the cost of painting house 00 with the color red, costs[1][2] is the cost of painting house 11 with the color green, and so on.

Return the minimum cost to paint all houses.

Constraints:

  • costs.length =n= n

  • costs[i].length =3= 3

  • 1≤n≤1001 \leq n \leq 100

  • 1≤1 \leq costs[i][j] ≤20\leq 20