LinkedIn·Software Engineer·Technical Phone Screen
- Given n houses in a row and k colors, where costs[i][j] is the cost of painting house i with color j and no two adjacent houses can share the same color, find the minimum total cost to paint all houses. Then optimize your DP solution from O(n*k^2) to O(n*k).
“The basic DP setup clicked pretty fast for me.”