diff --git a/Longest cycle in graph.cpp b/Longest cycle in graph.cpp new file mode 100644 index 000000000..46b365078 --- /dev/null +++ b/Longest cycle in graph.cpp @@ -0,0 +1,50 @@ +//https://leetcode.com/problems/longest-cycle-in-a-graph/submissions/ + +class Solution { +public: + + int maxLength = -1; + + void getcycle(vector &edges,int si,vector& visit,vector& store){ + if(si == -1)return ; + if(visit[si]){ + int count = -1; + for(int i =0;i& edges) { + + vector visit(edges.size(),0); + + for(int i =0;i store; + getcycle(edges,i,visit,store); + + } + + return maxLength; + + } +}; \ No newline at end of file