Starting 6 test cases failing. 3 passing test cases

In the CB numbers question my 3 test cases are passing and rest are showing wrong answers. Kindly help me out here.

Hey
Just Randomly I provided an input to your code i.e
4
4153
Also I just checked which substrings your program is considering so I printed them on the console by adding the bold line
stringstream cb(l);
int k=0;
cb>>k;
cout<<k<<endl;
Now your output is:
4
15
53
3
41
153
53
415
153
4153
Dont u think it should consider 5 as well? which it is not considering

Also this program of your gives output 3 to my test case by considering 53,3 and 41(Notice 53 and 3 are redundant as per question, so your approach is little wrong, try manipulating for loop structure in main )
Although the answer is 3 only,but by considering 5,3 and 41 as substrings

Look into this…And do tell me if u are facing any further issue !
PS: First Try debugging yourself by using cout statements at various places where you doubt your approach

I have rectified those mistakes still, I am failing 3 test cases.

Hey
There is one more small mistake that you are making.
This time I tested
4
1511
As per question the answer should be 2, either by taking 5,11
Now coming to your program, it is only considering 151 as valid CB number and giving output as 1.
Maybe you should consider checking your isValid function?
Please make these corrections and let me know how it goes…

1 Like

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.

1 Like