I had done an approach by which, a painter with least number blocks gets incremented.
Painter's partition problem
Hi Vivek,
In this problem, we need to assign continuous segments to each painter as mentioned in the question:
In the test case:
2
4
10 20 30 40
Painter 1: 10+20+30 = 60
Painter 2: 40
So our answer will be 60. But your code will give 50.
Try to use Binary search in this question and use long instead of int.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.