FastPrepDrawing Edge

Drawing Edge

Snowflake logoSnowflake● EasyOA
Learn

Problem statement

A network has n distinct nodes. Every pair of different nodes can either have one undirected edge or remain disconnected; self-edges are not allowed.

Return the number of distinct network configurations modulo 10^9 + 7.

Function

drawingEdge(n: int) → int

Examples

Example 1

n = 3return = 8

For three nodes A, B, and C, the possible edges are AB, AC, and BC. The eight configurations are:

  • no edges
  • only AB
  • only AC
  • only BC
  • AB and AC
  • AB and BC
  • AC and BC
  • all three edges

Each of the three edges has two independent states, so there are 2^3 = 8 configurations.

More Snowflake problems

See Snowflake hiring insights
public int drawingEdge(int n) {
  // write your code here
}
n3
expected8
Checking account…