Stuck in my approach to this question

i am able to find all the valid entries but i am stuck in finding the maximum number of non overlapping sub strings

here is my approach please have a look

hey can you please help in resolving the doubt

Hello @pradyumn25jain,

  1. To maximize the CB numbers:
    First check for all the sub-strings of length 1 and then gradually increase the size.

  2. To avoid overlapping:
    Use an array to mark the indexes as visited for elements present in the CB numbers that have already detected.

You can refer to the following code:

Let me know if you still face any issue.

Hope, this would help.
Give a like if you are satisfied.

alright thank you so much