Painter partition problem

https://practice.geeksforgeeks.org/problems/the-painters-partition-problem/0

this code shows wrong ans on submission…plz correct it …
i have tried using backtracking approach plz make changes in my code…
dont need binary search approach
reply at the earliest

why doesnt anyone reply???plz reply it been 2 days already

Why are u passing n-1 in one of recursive call in place of k. I didn’t get ur approach. Try to solve it using binary search

I am trying to do it by backtracking as everyone does it by binary search so it has become very common…
It can be solved by back tracking I know that but I am not able to solve it correctly…I am trying to divide it into brackets/sets and then find doff Ans and then min of max …

I have made some changes in ur code. Try this:

expalin the changes made…

Base Case: if k==1 then then just take the sum of all elements and return it.
Recursive Case: Make partition at every position of array and take max of all partitions. This max will represent the time taken to get the job done. Since we need to calculate the minimum time calculate the minimum of all possible max times.

I also tried doing that but why is my code giving wrong ans…