Please correct the code why 3 test case is failing
CB Number 3 test case failing
Hello @Ram_Vilash_Kumar,
-
The function: stoi(sub)
won’t work for the numbers greater than the range of int.
Solution:
Rather convert the string to a number explicitly. -
As you have to maximize the CB numbers, first check for all sub-strings of length 1 and then increase the size gradually.
-
Not accounting for the case mentioned in the question i.e.
CB number once detected should not be sub-string or super-string of any other CB number.
Solution:
Use a separate array to mark the index of the detected CB numbers as visited.
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.