Unable to find what have I done wrong as per the explained algo

import java.util.*;
public class Main {
public static void main (String args[]) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[]arr = new int[n];
for(int i=0;i<n;i++){
arr[i]=sc.nextInt();
}
if(checkCircular(arr)){
System.out.print(“1”);
}else{
System.out.print(“0”);
}
}

static int nextIndex(int[]arr,int i){
    return ((i+arr[i]+arr.length)%arr.length);
}

static Boolean checkCircular(int[]arr){
for(int i=0;i<arr.length;i++){
if(arr[i]==0){
continue;
}
int fast=i,slow=i;
while(slownextIndex(arr,slow)>0&&
fast
nextIndex(arr,fast)>0&&
fastnextIndex(arr,nextIndex(arr,fast))>0){
slow=nextIndex(arr,slow);
fast=nextIndex(arr,nextIndex(arr,fast));
if(slow==fast){
if(slow==nextIndex(arr,slow)){
break;
}
return true;
}
}
slow=i;
int val=arr[slow];
while(val
arr[slow]>0){
int x=slow;
slow=nextIndex(arr,slow);
arr[x]=0;
}
}
return false;
}
}

hello @atul51

pls save ur code here-> https://ide.codingblocks.com/

and share its link with me

Hi @aman212yadav
pls find the code here

here u are taking product of indices which is wrong.
u need to take product of values present at that indices

pls check ur updated code here->

Thanks alot for the quick support. :smiley:

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.