Finding CB numbers


I know I am missing something here plz run the code for the given test cases and check errors

Hi there are some errors in your code

  1. you should accept the size of the string then the string but you are not accepting the size
  2. u are using substr function wrongly as substr takes two arguments viz , the starting index of substring and size of substring not the ending index
  3. there is a logical error in your code
    consider this test case
    14
    23574414416111

according to your code logic answer should be 6 which are :-
2
3
5
7
44144161
11

but notice 44144161 Now we can have 41 41 61 three CB Numbers out of it
thus the actual answer is 8 .

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.