Question Approach Nothing much to see here. I couldn't think of any proper solution (the question is in the hard difficutly range imo) so I checked the editorial. Everything can be found there. I followed the Dynamic Programming solution