my code
Please help me in finding the error in my code?
there is one mistake
don’t sort the array otherwise it will give wrong ans
because in question it is mention that
Every painter can paint only contiguous segments of boards.
so if you sort the array contiguous will not remain contiguous
so no need to sort the array
now start=*max_element(arr,arr+n)
you can see the changes in modified code
Modified Code
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like
: and don’t forgot to mark doubt as resolved 