Painter's Problem-2 testcases not passed

Hey, I was trying this problem but unfortunately, I’m not able to solve it completely, I’m stuck with 2 test cases unpassed, here is the code I tried, could you help me in solving this by either correcting my code(please add comments, so that it hits me where I got wrong) or helping me with a approach, i used Binary search, divide and conquer approach btw

Thanks!

hey 2 things

  • array is not sorted so s will not always be a[n-1].
  • find max and then assign it to s

Oh Yeah ! Thanks for the instant help :smiley:

np :slight_smile: please mark your doubt as resolved and rate as well