CB Numbers Strings Question

I am not able to pass all the testcases can you let me know where I am going wrong?
https://ide.codingblocks.com/s/246560 also the question mentions in 4991 we can only take 499 or 991 whereas it is also mentioned that we can not take sub-strings or super-strings, how are these both sub-strings or super strings of each other. Isn’t this an ambiguity?

@rachitbansal2500 if you take both 499 and 991, 99 is overlapping in both the strings and that is not allowed

Hey but again:
CB number once detected should not be sub-string or super-string of any other CB number.
this is clearly mentioned.
These both are not sub-strings or super-strings, they just have some overlapping elements. When I did not consider overlapping elements 5 of my testcases were failing but now you can see only 2 are.

@rachitbansal2500 that is what the question meant though, and any confusion is cleared by the example given. I am sharing the editorial solution with you for your reference.

Please explain how can we ensure that we get the maximum number of CB numbers.

@rachitbansal2500 we consider the smallest possible CB number at every step, so that maximum amount of CB numbers can be formed

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.