Can any one explain the problem?.. no need to solve the problem ,just explain the question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any one explain the problem?.. no need to solve the problem ,just explain the question

A builder is looking to build a row of N houses that can be of K different colors. He has a goal of minimizing cost while ensuring that no two neighboring houses are of the same color. Given an N by K matrix where the nth row and kth column represents the cost to build the nth house with kth color, return the minimum cost which achieves this goal.

18th Oct 2020, 4:03 AM
Bharadwaj
Bharadwaj - avatar
1 Answer
+ 2
This is what I understood from the statement :- Let's say you have to build 3 houses with 2 different colours (say red(R),Black(B)) => N = 3 , K = 2 condition is that no 2 adjecent houses can have same colour means [R,R,B] is not a valid option while [B,R,B] is valid Now you are given a matrix (N*K) representing cost of building a house with specific color. Means that each row of matrix represents a house and column represents color, so A[I][j] will represent cost of building house "i" with colour "j". Your task is to minimise the cost of building N houses while keeping the condition intact.
18th Oct 2020, 4:18 AM
Arsenic
Arsenic - avatar