← Openai Interview Insights

Openai·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Apr 2026Remote

Summary

Got a graph theory problem for an OpenAI SWE round, the kind that looks deceptively clean on the surface but requires you to actually remember your Eulerian path theory from undergrad. One problem, pretty well-defined constraints, and you either know the trick or you don't.

Questions Asked (1)

Q1

Given an undirected graph where each edge must be drawn exactly once, find the minimum number of continuous strokes needed to draw all edges. A stroke can start anywhere and revisit vertices but cannot redraw an edge.

Algorithms & Data Structures
Author's notes

I recognized this as an Eulerian path/trail problem pretty quickly, which was lucky.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as the Route Inspection Problem (Chinese Postman Problem) for undirected graphs, where the minimum number of strokes equals the number of odd-degree vertices divided by 2 (or 1 if all degrees are even). Explain the reasoning: each stroke can cover at most two odd-degree vertices as endpoints, and by pairing odd vertices with shortest paths, you can achieve this lower bound. Then outline an algorithm to compute the answer.

Pro tip: Mention that this is a classic problem with a known polynomial-time solution, and that the answer is simply max(1, odd_count/2). This shows you can map new problems to known results, a key skill at OpenAI.

1. Identify the problem type

State that this is the Chinese Postman Problem (Route Inspection) for undirected graphs, where we want to cover all edges with minimum trails.

2. Analyze degree parity

Explain that in any graph, the number of vertices with odd degree is even. Each stroke (trail) has two endpoints, which must be odd-degree vertices (or the same vertex if the trail is a cycle).

3. Derive the lower bound

Argue that each stroke can cover at most two odd-degree vertices as endpoints, so at least odd_count/2 strokes are needed. If odd_count=0, at least 1 stroke is needed (unless the graph has no edges).

4. Show achievability

Describe how to pair up odd-degree vertices and add shortest paths between each pair to make all degrees even, resulting in an Eulerian graph that can be drawn in one stroke. Removing the added paths splits it into odd_count/2 strokes.

5. Provide the formula and complexity

Conclude that the minimum number of strokes is max(1, odd_count/2). Mention that computing odd_count is O(V+E), and if needed, the pairing can be done in O(V^3) using Floyd-Warshall and matching.

Key Points to Mention

  • The problem is equivalent to the Chinese Postman Problem for undirected graphs.
  • The number of odd-degree vertices is always even (handshaking lemma).
  • Each stroke can have at most two odd-degree vertices as endpoints.
  • The minimum number of strokes is max(1, odd_count/2).
  • If odd_count=0, the graph is Eulerian and can be drawn in one stroke.
  • Pairing odd vertices with shortest paths makes the graph Eulerian, proving achievability.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.