I didn’t understand the following two lines:
" CB number once detected should not be sub-string or super-string of any other CB number.
Ex- In 4991, both 499 and 991 are CB numbers but you can choose either 499 or 991, not both. "
I didn’t understand the following two lines:
" CB number once detected should not be sub-string or super-string of any other CB number.
Ex- In 4991, both 499 and 991 are CB numbers but you can choose either 499 or 991, not both. "
@prateek_5
It means that no two CB numbers should share a character for example in 4991, if you detect 499 as CB number then you cant use first, second and third character in the 4991 for other CB numbers.
means take these numbers out of the string , then form sub-string from the remaining numbers and check again. isn’t it?
How to get it done ?
@prateek_5 you cannot take them out in literal sense for example In, 994991, if you make 499, the string will not become 991, it’ll still remain 994991, just you wont be able to use 4, 9, 9. To do this question you must take all the substrings of length 1 followed by all the substrings of length 2 and so on and check if they are CB numbers if they are increment the counter and make the character unavailable for next substrings. Please try to code it, If unable to you can ask new doubt again.
only one test case passed.
what’s wrong with my code? 
one more question, this code gives output 2 for input 81615 on codechef ide, but CB ide gives 0.
why?
you have to use long long, and please explain to me how is your code checking all the subsstrigs of length 1 first and then length 2. is the given string is 123, your first substring should be 1, then 2, then 12, then 23 then 123 but you are not going about this way.
please refer to given code for help
please add comments to your code between line 42-76 so that it becomes easier for me to comprehend.
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.