Tap here to switch tabs
Problem
Submissions

Problem: Paint House II

med
30 min
Try to solve the Paint House II problem.

Statement

There is a row of nn houses, where each house can be painted with one of the kk colors. The cost of painting each house with a specific color is represented by an nimeskn imes k cost matrix costs, where costs[i][j] represents the cost of painting house i with color j.

All houses must be painted such that no two adjacent houses have the same color.

Return the minimum total cost required to paint all houses.

Constraints:

  • costs.length ==n== n

  • costs[i].length ==k== k

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

  • 2≤k≤202 \leq k \leq 20

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Paint House II

med
30 min
Try to solve the Paint House II problem.

Statement

There is a row of nn houses, where each house can be painted with one of the kk colors. The cost of painting each house with a specific color is represented by an nimeskn imes k cost matrix costs, where costs[i][j] represents the cost of painting house i with color j.

All houses must be painted such that no two adjacent houses have the same color.

Return the minimum total cost required to paint all houses.

Constraints:

  • costs.length ==n== n

  • costs[i].length ==k== k

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

  • 2≤k≤202 \leq k \leq 20

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