Challenge: Count the Number of Edges in an Undirected Graph

Try to solve the Count the Number of Edges in an Undirected Graph problem.

We'll cover the following

Statement

Given an n number of nodes in an undirected graph, compute the total number of edges.

Constraints:

  • 00 \leqn102 \leq 10^2

  • 00 \leqedges.length n(n1)/2\leq n(n-1)/2

  • edges[i].length ==2== 2

  • 1x,y1 \leq x,y \leqn

  • xyx\neq y

  • There are no multiple edges between any two vertices

  • There are no self-loops

Examples

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.