How to solve Code Chronicles's WANNABET?

https://www.codechef.com/CHIL2020/problems/WANNABET
can someone say the approach for this problem

1 Like

checkout the editorial here

2 Likes