I have used the following recursive approach for this problem
public static int calmin(int arr[],int k,int index,int n,int pra){
if(index==n)
return 0;
if(pra==0)
return 0;
int ans1=0,ans2=0;
ans1=ans1+(arr[index]*k)+calmin(arr,k+1,index,n,pra-1);
ans2= ans2+(arr[index])+ calmin(arr,k,index+1,n,pra-1);
return Math.min(ans1,ans2);
}
I am getting wrong answer for this, whats wrong with this solution, why is it not working. There will be 2 cases for this problem, either i will take the same cook again for i will add his time and go to the next, thats what i have done in this algo, why didnt it worked?