Help Needed - PADTREE

This is the link to the problem. I came across this solution but unable to understand it.

Anyone explain this logic. @samarth2017 @tuananh238 @tamo11 @rishabh_singh0 @taran_1407 .Thanks in advance !!

7021641947 text me on whatsapp