What is wrong in my code.Why all test cases are not getting passed.
Finding CB Numbers
Hi is there anyone available to help solve my problem?
In your approach when you are checking a substring for CB number you are not checking for substrings that are inside that substring. For example if string is 4416618111011 then your code is computing CB numbers as 44166181 , 11 and 11. Which is having 2 reasons to get wrong :
- 11 is included two time. (and ques says that only 1 time a CB number should be included in final answer)
- in substring 44166181 there are 2 substring 41 and 661 which are also CB number so instead of that large string we should consider these two small sub string.
so what i need to do is form all the substrings and then from that collection check which all are feasible so that final ans is also max
yes … along with this you have to keep checking if that substring you have already included or not.