← Airbnb Interview Insights

Airbnb·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Apr 2026

Summary

Airbnb software engineer interview with a graph optimization problem. Pretty niche question that took me a minute to wrap my head around, but once I saw it as a path-scoring problem it clicked.

Questions Asked (1)

Q1

You're given a directed graph with edge costs and per-node rewards. Starting from a fixed start node, traverse edges until you reach any end node. The score is the total node rewards collected minus the total edge costs paid. Find the maximum achievable score.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Took me a second to not just reach for Dijkstra out of habit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a longest path in a directed graph with node weights and edge costs, which is NP-hard in general due to positive cycles. Clarify with the interviewer whether the graph is a DAG or if cycles are allowed; if a DAG, use dynamic programming with topological order; if cycles exist, discuss the implications and potential approaches like Bellman-Ford for longest paths with cycle detection or heuristics.

Pro tip: Always ask clarifying questions about graph properties (e.g., cycles, negative edges) before diving into a solution—this shows you understand the problem's complexity and can adapt your approach based on constraints.

1. Clarify problem constraints

Ask about graph size, whether it's a DAG, if cycles are allowed, and if rewards/costs can be negative. This determines the algorithmic approach.

2. Identify problem type

Recognize that this is a longest path problem with node weights and edge costs. In general graphs, it's NP-hard if positive cycles exist; in DAGs, it's solvable in linear time.

3. Choose algorithm based on constraints

For DAGs, use topological sort and DP to compute max score to each node. For general graphs, discuss Bellman-Ford for longest paths with cycle detection, or if cycles are positive, the answer may be infinite.

4. Define DP recurrence and handle end nodes

Define dp[v] as max score to reach v. Initialize dp[start] = reward[start]. For each edge u->v, dp[v] = max(dp[v], dp[u] + reward[v] - cost(u,v)). The answer is max dp[end] over all end nodes.

5. Analyze complexity and edge cases

Discuss time/space complexity (O(V+E) for DAG, O(VE) for Bellman-Ford). Handle unreachable end nodes, negative scores, and cycles that may cause infinite scores.

Key Points to Mention

  • Graph properties: DAG vs. general graph, presence of cycles, negative weights
  • Longest path problem and its NP-hardness in general graphs
  • Dynamic programming with topological sort for DAGs
  • Bellman-Ford algorithm for longest paths and cycle detection
  • Handling multiple end nodes and unreachable nodes
  • Time and space complexity trade-offs

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