Painter's partition problem

please tell me why its is not passing all test cases.

hi @sonumittal,
it’s because without sorting painter is doing work on contiguous sections of board,but when you sort it boards not remain connected.
Please let me know if there is any other doubt.