FastPrepDrawing Edge
Problems/Drawing Edge

Drawing Edge

IBM logoIBM● EasyFULLTIMEINTERNOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The displayed screenshot contains the statement, modulo rule, n = 4 example, and function name. The parameter type, 1 <= n <= 10^9 bound, and n = 2 example are corroborated by a matching IBM assessment continuation.

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) → int

Examples

Example 1

n = 4return = 64
Example 1 illustration

Four 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 = 2

There 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

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int drawingEdge(int n) {
      // Write your code here.
    }
}
Checking account…