test cases are not passing
where is problem? I cant find
Finding CB numbers
Hello @dhairya16,
-
You should first check for all the sub strings of length 1 and then of length 2 and so on…
reason:
You have to find the maximum CB numbers.
So, first look for the smallest one.
It might be possible a bigger CB number your code might detect have multiple smaller number in it. -
you should also check if no is present in cb[] before checking for no%cb[i]
If it is present then it is a CB number and return true. -
maintain a visited array of type bool.
It will keep track of those indexes that are contributing to an already detected CB number.
This way you can avoid using the same index in more than 1 CB number.
Hope, this would help.
Give a like if you are satisfied.
my implementation of checkValid is correct ?
Hello @dhairya16,
No, it won’t help.
-
As you are checking for the digit instead of the index.
It could be possible that the same digit(the not index) is common to two different CB numbers.
Example:
4
1119
11 and 19 are two CB numbers having digit 1 in it. -
You should only mark the index true if it is the part of a valid CB number. Else, you might end up detecting zero CB numbers.
Example:
4
1119
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.