2 test case still not passing please tell my mistake

	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	String s = sc.next();
	boolean[] a = new boolean[1_000_000_0];
	Arrays.fill(a, true);
	a[0] = false;
	a[1] = false;

// if u get a true i.e. its prime therefore mark all its multiple false this gives a array with prime number index true
for (int i = 2; i * i < 10000000; i++) {// applying sieve or eratosthenes
if (a[i]) {
for (int j = i * i; j < 1_000_000_0; j += i) {// mark multiple false
a[j] = false;
}
}
}
for (int i = 30; i * i < 10000000; i++) {
if (a[i]) {
for (int j = i; j < 1_000_000_0; j += i) {
a[j] = true;
}
}
}
int c = 0;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
String ss = s.substring(i, j);
int x = Integer.parseInt(ss);
if (a[x]) {
c++;
i = j;
}
}
}
System.out.println©;

  • 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.

refer to this here: