Please check my code once and let me know the corner cases where it may fail, as my code isn’ passing test case 0 and test case 1.
Link to my code-
Please check my code once and let me know the corner cases where it may fail, as my code isn’ passing test case 0 and test case 1.
Link to my code-
@7nishit Just remove the sort function from your code. It will work because you are changing the order of the painted lengths.
It worked but I didn’t get the reason behind removing the sort function.
Is it because of the following line in the problem statement?
any painter will only paint contiguous sections of board. - this section of the problem statement
@7nishit Yes any painter can paint only contiguous section. And if you would change the order by sorting you’ll definitely get a wrong answer