Failing some test cases

Finding CB numbers
Why am i failing testcases 6, 7, 8.
https://ide.codingblocks.com/s/142233

Hello @ashishxharma3462,

  1. There is a problem in the conversion of string to int.
    The string can be greater than the range of int.
    Thus, the stoi() would fail for that case.
    Solution:
    Explicitly convert the string to a number.(using loop)

  2. If you would print num, then you would realise that your code is initially checking for all the subarrays/substrings that are starting from index i=0. And after detecting a CB number, it makes i=j+1. Correct?
    Like in the example mentioned in my previous reply, it detected two CB numbers though actually there were 4 CB numbers:
    Example:
    11
    44166181111
    Your Output:
    2
    Detected CB numbers:
    44166181
    11
    Actual:
    41
    61
    11
    11

Solution:

Check for all the substrings starting from smallest size i.e. 1, then gradually increase the size.
Also, use an array to mark the indexes that are used in the CB numbers that are already detected.
Correct your code and let me know if you don’t understand something.

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

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.