← Liftoff Interview Insights

Liftoff·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Liftoff software engineer interview with a graph problem that looked like a LinkedIn-degrees-of-separation question. Pretty standard BFS territory but they wanted you to handle edge cases and optionally reconstruct the path, which is where things got more interesting.

Questions Asked (1)

Q1

Given an undirected graph of n people and a list of connections between them, find the minimum number of degrees of separation between two given people. Return 0 if they're the same person, -1 if unreachable, and optionally reconstruct the actual shortest path if asked.

Algorithms & Data Structures
Author's notes

Classic BFS and I knew it immediately, which honestly made me a little sloppy at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as an unweighted graph and use BFS from the source to find the shortest path to the target, as BFS guarantees the minimum number of edges. Handle edge cases upfront (same person, disconnected graph) and maintain a parent map to reconstruct the path if needed.

Pro tip: Mention that BFS is optimal for unweighted graphs and that bidirectional BFS can significantly reduce search space in large graphs. Also, clarify with the interviewer whether the graph is connected and if the path reconstruction is required, as this affects the implementation.

1. Clarify requirements and edge cases

Confirm if the graph is undirected, if nodes are 0-indexed or 1-indexed, and whether path reconstruction is needed. Handle trivial cases: if source == target, return 0; if either node is not in the graph, return -1.

2. Choose BFS as the algorithm

Explain that BFS is ideal for finding shortest paths in unweighted graphs because it explores nodes in order of distance from the source. Mention that DFS would not guarantee the shortest path.

3. Implement BFS with distance tracking

Use a queue to traverse the graph level by level, keeping track of visited nodes and their distances from the source. Stop when the target is found and return the distance.

4. Reconstruct path if required

Maintain a parent map during BFS to record the predecessor of each visited node. Once the target is reached, backtrack from target to source using the parent map to build the shortest path.

5. Analyze complexity and optimize

State that time complexity is O(V + E) and space is O(V). For very large graphs, discuss bidirectional BFS to reduce time and space, and mention adjacency list representation for efficiency.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Time and space complexity: O(V + E) time, O(V) space
  • Handling disconnected graphs and returning -1
  • Using a parent map for path reconstruction
  • Bidirectional BFS as an optimization for large graphs
  • Adjacency list representation for sparse graphs

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