Painter Problem 2 failed testcase

plzz… check my code
and suggest solution where my code fails for test cases

hello @Pramod123

a) dont sort the array becuase painter can only paint continuous section
b) use long long in place of int to avoid overflow.

if array is not sorted then only 2 test cases passes but when array is sorted then 4 test cases passed

with what value u have initialsied ur s?

ur start variable should contain maximum value of the array.