Drawing Edge
Updated
Problem statement
You are given n labeled vertices. For every unordered pair of distinct vertices, you may either draw one undirected edge between them or leave them disconnected.
A graph may be disconnected. Two graphs are different when at least one pair of vertices has a different edge choice.
Return the number of distinct simple undirected graphs that can be formed, modulo 10^9 + 7.
Complete drawingEdge with the parameter int n and return the result as an int.
Function
drawingEdge(n: int) → intExamples
Example 1
n = 4return = 64Four vertices determine 4 * 3 / 2 = 6 possible edges. Each edge can be absent or present independently, so the number of graphs is 2^6 = 64.
Example 2
n = 2return = 2There is one possible edge between the two vertices. It can be absent or present, so there are 2 graphs.
Constraints
1 <= n <= 10^9
More IBM Online Assessment questions
- Missing IntervalsOA · Seen Nov 2026
- Count Peaks and ValleysOA · Seen Nov 2026
- Last Object Exit TimeOA · Seen Nov 2026
- Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
- Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
- Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
- Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
- Tree Pythagorean TriplesOA · Seen Oct 2026
- Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
- Maximum Compatible Time WindowsOA · Seen Oct 2026
Similar questions at other companies
- Drawing EdgeWeRide · OAWeRide interview questions
- Drawing EdgeSnowflake · OASnowflake interview questions
- Count OperationsWells Fargo · OAWells Fargo interview questions
- Enough Muffins for the LineSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Next Pascal Row CoefficientIntuit · OAIntuit interview questions
- Subarray SumVisa · OAVisa interview questions
- Process SchedulingCitadel · OACitadel interview questions
- Unique Digits in RangeAgoda · OAAgoda interview questions
- Ordered Book Displays with a Featured BookIMC Trading · OAIMC Trading interview questions
- Find Max Number of PairsRoblox · OARoblox interview questions