What is wrong in the code
Hello @17manishms,
-
You should first check for all the substrings 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 mark an index visited only if it is the part of any CB number.
Solution:
if(!visited(v,i,j))
//Add inside the if condition:
{
count++;
for(int m=i;m<=j;m++)
{
v[m]=1;
}
}
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.