Only 1 test case got passed
Hello @Pranav_Chaudhary,
-
The following function terminates for the string with length greater than 10
int num=Integer.parseInt(number.substring(i, j+1));
Also, the converted value can be long. -
You have start from all the substring of length 1 and then increment the size of substring as you have to find the maximum CB numbers.
In your code, you are first checking for all the substrings starting from i=0, then all substrings from i=1 and so on. This way you would skip some CB numbers
Solution:
for(int i=1;i<=number.length();i++) {
for(int j=0;j<=number.length()-i;j++) {
//Check for substring(j,j+i)
}
} -
Create an array visited to keep track of indexes that have been used in the CB numbers that have been detected till now.
-
A CB number is a prime number, if you observe it very carefully.
If you still face any issue, let me know.
I hope, this would help.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.