Wine problem bottom up approach

actually i got the bottom up logic but i am not able to code it so please help me out in that.


check this video at 35 :00 timestamp