why it is giving wrong output for some test cases
Finding cb number
Hey @suhailrashidsalma it is mentioned in the question that a character in a string can only be used once. So if we want to maximize the number of cb numbers we would first find cb numbers of length 1 in the string then length 2 and so on.
so instead of looping over string like
for(ll i=0;i<n;i++){
for(ll j=i;j<n;j++){
loop over it like this.
for(ll i = 1; i <= n; i++){
for(ll j = 0; j <= n - i; j++)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.