MCHEF 1D DP Solution ?

Hi, can someone please explain MCHEF 1D DP solution, example this one.

It would be really helpful.

Thanks.

hi vimal

if you did not solve mchef with 2D array then first go for it because probably you think that there are two way to solve this question first with 1D array and second with 2D array but funny thing is that both are same there is no difference in logic

the difference is that in 2D array we keep previous value and store new optimum value in next row of matrix, BUT in 1D array we take(observe) previous value from array and REPLACE the current value with optimum value :slight_smile: so i think it is not difficult to use 1D array because concept is same if you know 2D solution then you can definitely solve it using 1D array by your self.
still you have doubt then you can ask me :slight_smile:

2 Likes

I tried a lot and I came up with this solution.

But it’s still not giving right answer for the given test case in problem statement. Can you please tell me where I am going wrong ?

Thanks.

I was like #$%#!@# … on seeing that i took input in wrong order ( i took as “n,m,k” but it was “n,k,m”).

1 Like