I am not able to figure out the logic for this code. please make a video on this question or provide a better explanation for thus.
Problem writing this code
@Mudit809They are not considering 4991 as a CB number.
Instead, 499 and 991 are CB number that can be formed from the above number 4991.
But, we can select only one as the multiple uses of the same character is not allowed and 99 is common to both.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.
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.
Hope, this would help.