PROBLEM 3: Paint Houses into k colors.
On some street, there is a row of n houses. Each house may be painted in one of k colors. The cost of painting each house with a certain color may be different. You must paint all the houses so that no two adjacent houses have the same color. The cost of painting each house with a certain color is represented by an n x k matrix costs. For example, costs[0] is the cost of painting house i with color 0, costs[1] is the cost of painting house i with color 1, costs[2] is the cost of painting house i with color 2, etc. You need to find the minimum cost to paint all houses as well as the list of colors used for it.
(a) [18 POINTS] Write SRT BOT for this problem.
(b) [12 POINTS] Implement top-down recursive dynamic program that solves this problem.
(c) [12 POINTS] Implement bottom-up iterative dynamic program that solves this problem.
Example 1.
INPUT: costs = [[8, 2, 4], [10, 4, 20], [6, 3, 4], [4, 8, 7]]
OUTPUT: 16, [2, 1, 2, 0]
EXPLANATION: The best option is to paint house 0 into color 2, house 1 into color 1, house 2 into color 2, and house 3 into color 0. This will cost a total of 4 + 4 + 4 + 4 = 16.
Example 2.
INPUT: costs = [[4, 6], [1, 12]]
OUTPUT: 7, [1, 0]
EXPLANATION: The best option is to paint house 0 into color 1 and house 1 into color 0. This will cost a total of 6 + 1 = 7.