Please go through my code (comments mentioned for understanding)
there can be cb number as well that are non prime for example
37*37 (it is not prime but it is cb number)
would you pls check it again
help me out pls,now i have changed the prime checking condition to CB checking condition but still no test case is being passed
Debug for this
8
86922395
Output
4
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.
you can see this:
1 Like