Cycle detection usind dsu

not getting correct answer

Hey @rupesh-4819

   int find_set(int i,int *parent){
      //base case
      if(parent[i]==-1){
          return i;  //i here
      }
        return find_set(parent[i],parent);
   }
1 Like

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.