Edges should have to be n - 1 where n is the number of vertexes
only tree possible
const edges = [ ]; function hasCycle(edges) { let count = 0; for (let vetex = 0; i < edges.length; vertex++) { count += edges[vertex].length; } return Math.floor(count / 2) === edges.length ? true : false; }
No. Use DFS
Last updated 1 year ago