You are given an integer n, representing the number of vertices in an undirected graph numbered from n edges, where edges[i]
Initially, the graph contains no edges. You process the edges in edges one by one in the given order. An edge is added to the graph if and only if adding it does not form any cycle with an odd total weight.
Return the total number of edges successfully added to the graph.
Constraints:
n
edges.length
edges[i]
n
All elements in edges are distinct.
You are given an integer n, representing the number of vertices in an undirected graph numbered from n edges, where edges[i]
Initially, the graph contains no edges. You process the edges in edges one by one in the given order. An edge is added to the graph if and only if adding it does not form any cycle with an odd total weight.
Return the total number of edges successfully added to the graph.
Constraints:
n
edges.length
edges[i]
n
All elements in edges are distinct.