Tap here to switch tabs
Problem
Submissions

Problem: Determine if a Simple Graph Exists

med
30 min
Try to solve the Determine if a Simple Graph Exists problem.

Statement

Given an integer array degrees of length nn, determine whether there exists a simple undirected graph with nn vertices such that the degree of the vertices matches the elements in degrees.

Return true if such a graph exists, or false otherwise.

Note: A simple graph is an undirected graph with no self loops and no multiple edges between any pair of vertices.

Constraints:

  • 1≤n==1 \leq n == degrees.length ≤105\leq 10^5

  • 0≤0 \leq degrees[i] ≤n−1\leq n - 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Determine if a Simple Graph Exists

med
30 min
Try to solve the Determine if a Simple Graph Exists problem.

Statement

Given an integer array degrees of length nn, determine whether there exists a simple undirected graph with nn vertices such that the degree of the vertices matches the elements in degrees.

Return true if such a graph exists, or false otherwise.

Note: A simple graph is an undirected graph with no self loops and no multiple edges between any pair of vertices.

Constraints:

  • 1≤n==1 \leq n == degrees.length ≤105\leq 10^5

  • 0≤0 \leq degrees[i] ≤n−1\leq n - 1