hey, I came across this oracle interview question
if someone can help me with it. thankyou
here's the question
Arya has N balls arranged in a row. Some balls are colored and some are not. There are some M types of colors in Arya’s world and color balls have colors out of only these given M colors.
Arya decided to color the remaining balls and put all the adjacent balls with same color in 1 group. For example lets say after coloring the rows of balls have these colors :
{1, 2, 2, 3, 3, 3, 1, 1, 4, 5}. Then Arya can put them into following 6 groups : {1}, {2, 2}, {3, 3, 3}, {1, 1}, {4} and {5}. Arya wants these number of groups to be exactly K.
Now the coloring also has some cost associated. So as already told that there are M colors, coloring each ball i with color j costs C(i, j).
Arya want to use minimum paint for this task. You need to help her.
It is guaranteed that we can paint the balls such that K groups are formed.
input format
first line contains n,m,k(1<=k<=n<=100,1<=m<=100)number of balls ,number of colors number of target group
second line contains xi initial color of ball(xi=0 if intial color is none)
next n line each follows m integers. the jth number on ith index is the cost C(i,j)
output format
output the minimum number of paint required to make k groups.
test case 1
3 2 2
0 0 0
1 2
3 4
5 6
output
10
test case 2
3 2 3
2 1 2
1 3
2 4
3 5
output
0