i was trying to solve the buying fruit problem then i was thinking if i could divide in three different functions and write
arr1[]={1,50,50},arr2[]={50,50,50},arr3[]={1,50,50}
func1(int i,int n,int* arr1)
{
min(arr1[i]+func2(i+1,n,arr2)+func3(i,n,arr3))
}
func2(int i,int n,int* arr2)
{
min(arr2[i]+func3(i+1,n,arr3))
}
func3(int i,int n,int* arr3)
{
min(arr3[i])
}
i have not wriiten the base cases but will this work?