Finding CB Numbers

To solve this problem I first calculated all the prime numbers and then formed all the sub-strings of the given number to check whether that sub-string is CB number ( prime number )or not. But the problem is that I am not able to check the case when one sub-string is present in another sub-string.
Here is the code that I have implemented: https://ide.codingblocks.com/s/297201

Hey @anugrahrastogi
I first calculated all the prime numbers // these things are wrong

  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.
    2,3,5,7,11,13,17,19,23,29 //Only, These prime numbers are CB numbers.

Pls read my question and see what I am asking and I did not understand what you are trying to explain, this is already given in the question.

  1. There is no need of calculating primes:

  2. you can directly create an array and initialize it with the CB numbers given in the question.
    i.e. 2,3,5,7,11,13,17,19,23,29

  3. Make an array visited[n], to mark the indexes as visited (i.e. set it to true).
    This will help in keeping track of all the indexes of input array that have already been used in the previously detected CB number.

  4. Start checking from all the subarrays/substrings of smallest size i.e. 1 and then gradually increase the size.

I did not understand 3rd and 4th point, can you explain with the help of example?

@anugrahrastogi
please refer this link

I want to give you @Monu-Singh-480654572341490 a suggestion and it’s a humble request, please try to explain in a more elaborate and clear way. And I asked for an example so that I could understand the logic and then code it myself because I did not understand points 3 and 4, an example would have given me a better insight of the question. If I would have wanted the code I could have directly seen the editorial instead of asking the doubt here. And even after an example if I am not able to understand then providing the code would be fine.

I am really not satisfied with the way you clear doubts :disappointed: