Sample Case Ambiguous

In point two there is number “5” on the list, I am assuming that they are prime numbers.

In point three it is mentioned if the number is divisible by any number in the list is not CB number.
In Sample Case, It is mentioned that 5 is CB Number.

Can you please explain it briefly why 5 is CB Number even after it is divisible by “5” in the given list?

2,3,5,7,11,13,17,19,23,29 are CB numbers.
" if the number is divisible by any number in the list is not CB number. " means multiples of those numbers are not CB number.
Like 4, 6, 10, 14 etc are not CB numbers because they are divisible by 2, (3 or 2), 5, (7 or 2) respectively.

  1. 0 and 1 are not a CB number.
  2. 2,3,5,7,11,13,17,19,23,29 are CB numbers.
  3. Any number not divisible by the numbers in point 2( Given above) are also CB numbers.
    As to work on substrings of the given number, we will capture the element into the String instead of integer .
    The number ‘n’ given is nothing to do with our approach(as we are working on String) but can be useful acoording to your approach.

Intuition :

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.

1 Like


you can see this

Please mark your doubts as resolved in your course’s. and please rate your experience here

1 Like