Skip to main content
Graph Valid Tree | AlgoCracked
AlgoCracked
ProblemsGraph Valid Tree
Medium45.0% acceptance
Blind75DfsBfsGraphUnion Find

Graph Valid Tree

You are given n nodes labelled 0 … n-1 and a list of undirected edges , where edges[i] = [a, b] . Return true if these edges form a valid tree : the graph must be fully connected and contain no cycles. Input format Input is [n, edges] , e.g. [5,[[0,1],[0,2],[0,3],[1,4]]] .

Loading workspace…