Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
class Solution { public: // Function to detect cycle in an undirected graph. vector
visited; bool dfs(int node, int parent, vector
adj[]) { visited[node] = true; for(int neigh : adj[node]) { if(!visited[neigh] ) { if(dfs(neigh, node, adj)) return true; } else if(neigh != parent) { return true; } } return false; } bool isCycle(int V, vector
adj[]) { visited = vector
(V + 1, false); for(int i = 1; i <= V; i++) { if(!visited[i]) { if(dfs(i, 0, adj)) { return true; } } } return false; } };
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)