For the solution, I have initially set i as 1 and j to n as we need to take left element and right element int o consideration for each element.
so, let’s say if we have only 1 book i.e 1 2 1… (2 being the cost and 1’s are added to left and right) . For the condition specified above, i is set to 1 and j also to 1.
To find the cost, I have used expression as arr[i-1] * arr[k] *arr[j+1]. Please let me know where I am going wrong with this approach only.