Painter Problem doubt

unable to clearly understand the given output need some hints

Divya, I would suggest you to go through this video for the better understanding of the problem , and how to approach it,