Problem in writing code

i am able to visualize the steps but not able to code this properly. please check if my logic is correct.

1-take in the size of value of the string

2-find all the substrings in that string

3-sort all substring in order of the stringlength(increasing order).

4-check in increasing order if each substring is a CBnumber or not. and increment a variable say count.

5-move on to the next substring and do the same as mentioned in point 4 . also we need to keep checking if any previous substring is present in the current one if so we ll not consider it as a CB number

6-finally output the variable count.

Hey @ashishxmathew
Yup this approach is correct as well

Another approach

  • Put loop on string that will give substring of every length.
  • create a function that will return true if the passed number is a CB number otherwise return false.
  • To put a check if the digit is already a part of the any other CB number, create an boolean array say, valid which store which digits till now has been a part of any other CB number.
  • Take a counter and increment if a CB number is found.
  • At the end print the count.
    code :- https://ide.codingblocks.com/s/352807 2

Imp point to note is : CB number once detected should not be sub-string or super-string of any other CB number.so 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.