Algo-Phantoms / Algo-Tree

Algo-Tree is a collection of Algorithms and data structures which are fundamentals to efficient code and good software design. Creating and designing excellent algorithms is required for being an exemplary programmer. It contains solutions in various languages such as C++, Python and Java.
MIT License
356 stars 624 forks source link

Update readme.md #2059

Closed ranisnehal closed 3 years ago

ranisnehal commented 3 years ago

Related Issue

Describe the changes you've made

A clear and concise description of what you have done to successfully close your assigned issue. Any new files? or anything you feel to let us know!

Language Used:

[Mention the Language of Code]

Checklist:

github-actions[bot] commented 3 years ago

AlgoTree team will review your PR soon. Take Care of Few of the Things where most contributors are missing out. msgonpr @ranisnehal :)

ranisnehal commented 3 years ago

/ Here is the solution of the program in c++/

include<bits/stdc++.h>

include

using namespace std;

class solution{ public:

bool solve(int src , vector<int> &vis, vector<int> &order,vector<int> adj[]){
    vis[src]= 1;
    order[src]= 1;
    for(auto x:adj[src])
    {
      if(!vis[x])
       {   
         bool conf = solve(x,vis,order,adj);
         if(conf == true)
         return true;
        }
     else if(order[x])
      return true;
    }
    order[src] = 0;
    return false;
}

bool iscyclic(int v,vector adj[]) { vector vis(v,0); vector order(v,0); for(int i=0;i<v;i++) { if(!vis[i]) { bool c = solve(i,vis,order,adj); if(c==true); return true; } } return false; } };

time complexity:- O(v)

ranisnehal commented 3 years ago

fixed issue #2056 and #2059 using c++

ranisnehal commented 3 years ago

#

ranisnehal commented 3 years ago

@ranisnehal