Painter Partition Problem

I think so my logic is correct but one test case is not passing. Please can you help if I’m missing some corner case or something else.

Hey @aroraswati859 You code is failing test case :
8
5
8000 8565 8050 1234 1111
correct output = 8565
Your Output = -1

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.