← Databricks Interview Insights

Databricks·Software Engineer·Onsite - Coding / Algorithms·Intermediate

Intermediate
May 2026

Summary

Databricks software engineering interview with three back-to-back technical problems covering graph algorithms, dynamic programming, and interval manipulation. The questions were solid and felt like they were testing whether you actually think about edge cases rather than just pattern-match to a known solution.

Questions Asked (3)

Q1

You have a directed weighted graph where each edge has a travel time and a transport mode (walk, bus, subway, bike). Given a source, destination, and a set of allowed modes, find the minimum-time path using only edges whose mode is in the allowed set. Describe your algorithm and analyze complexity. Follow-up: if all modes are allowed, what changes?

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

Pretty much Dijkstra with a pre-filter step.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a shortest path on a directed weighted graph, filtering edges by allowed modes. Use Dijkstra's algorithm with a priority queue to efficiently find the minimum-time path. Analyze complexity in terms of vertices, edges, and allowed modes, and discuss the follow-up by noting that filtering becomes unnecessary when all modes are allowed.

Pro tip: Mention that if the graph is large, you can pre-filter edges or use a mode-aware adjacency list to avoid checking modes during traversal. Also, clarify that Dijkstra's algorithm requires non-negative weights, which travel times typically are.

1. Clarify the problem and assumptions

Confirm that edge weights (travel times) are non-negative, the graph is directed, and modes are edge attributes. Ask if multiple edges between same nodes with different modes exist.

2. Choose the algorithm

Select Dijkstra's algorithm because it efficiently finds shortest paths in graphs with non-negative weights. Explain why BFS is not suitable due to weighted edges.

3. Adapt for allowed modes

During relaxation, only consider edges whose mode is in the allowed set. This can be done by checking the mode before relaxing or by pre-filtering the adjacency list.

4. Analyze complexity

With a binary heap, time complexity is O((V + E) log V) or O(E log V) depending on implementation. Space complexity is O(V + E) for the graph and O(V) for distances.

5. Address the follow-up

If all modes are allowed, the mode filter is removed, so the algorithm remains the same but with no mode checks. Complexity is unchanged, but constant factors may improve.

Key Points to Mention

  • Dijkstra's algorithm and its requirement for non-negative weights
  • Priority queue implementation and time complexity
  • Edge relaxation with mode filtering
  • Handling multiple modes per edge or multiple edges between nodes
  • Space complexity and graph representation (adjacency list)
  • Follow-up: no change in algorithm, just remove filtering

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

Q2

Given n non-negative integers representing cash in houses arranged in a circle, find the maximum amount you can steal if you cannot rob two adjacent houses and the first and last houses count as adjacent.

Algorithms & Data Structures
Author's notes

Classic house robber 2.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Recognize this as a variation of the House Robber problem with a circular constraint. Break the circle by considering two linear cases: robbing houses 0 to n-2 (excluding the last house) and robbing houses 1 to n-1 (excluding the first house). Compute the maximum for each using dynamic programming and return the larger result.

Pro tip: Explicitly discuss the trade-off between time and space complexity, and mention that you can optimize space to O(1) by keeping only the last two DP values. This shows you think about efficiency beyond the basic solution.

1. Clarify the problem

Restate the problem to ensure understanding: houses are in a circle, adjacent houses cannot both be robbed, and the first and last are adjacent. Confirm that the input is an array of non-negative integers and that you need to return the maximum sum.

2. Break the circle into two linear cases

Since the first and last houses are adjacent, they cannot both be robbed. So consider two scenarios: (a) rob houses from index 0 to n-2 (exclude last), and (b) rob houses from index 1 to n-1 (exclude first). The answer is the maximum of these two cases.

3. Solve the linear House Robber problem

For a linear arrangement, use dynamic programming: dp[i] = max(dp[i-1], dp[i-2] + nums[i]). This ensures no two adjacent houses are robbed. Handle edge cases like empty array or single house.

4. Optimize space

Instead of an array, keep only two variables to represent dp[i-1] and dp[i-2], reducing space complexity from O(n) to O(1). Update them iteratively while traversing the houses.

5. Combine results and handle edge cases

Return the maximum of the two cases. For n=1, return the single house's value. For n=2, return the max of the two houses. Ensure the solution works for all edge cases.

Key Points to Mention

  • Dynamic programming approach for linear House Robber
  • Circular constraint handled by splitting into two linear cases
  • Time complexity O(n) and space complexity O(1) after optimization
  • Edge cases: n=0, n=1, n=2
  • Explanation of why splitting into two cases covers all possibilities
  • Comparison with alternative approaches (e.g., recursion with memoization) and why DP is better

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

Q3

Given a sorted list of non-overlapping half-open intervals, implement a function that deletes a given interval from the list, splitting existing intervals as needed. Follow-up: how would you handle a high-throughput stream of delete operations efficiently with bounded memory?

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The base function wasn't bad.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the interval semantics (half-open, sorted, non-overlapping) and walk through the deletion logic with examples, focusing on the three cases: no overlap, full overlap, and partial overlap (splitting). Then, for the follow-up, discuss how to handle high-throughput deletes by using a balanced BST or interval tree for O(log n) updates, and address bounded memory via streaming or compaction strategies.

Pro tip: Explicitly state that you're treating intervals as half-open to avoid off-by-one errors, and mention that you'd write unit tests for edge cases like deleting an interval that exactly matches an existing one or spans multiple intervals.

1. Clarify requirements and edge cases

Confirm that intervals are half-open [start, end), sorted, and non-overlapping. Ask about input size, whether the delete interval can be empty, and expected output format.

2. Design the deletion algorithm

Iterate through intervals, and for each, determine if it overlaps with the delete interval. If no overlap, keep it; if fully covered, remove it; if partially overlapped, split into up to two intervals.

3. Analyze complexity and optimize

For a single delete, O(n) is optimal if the list is an array. For multiple deletes, consider using a balanced BST or interval tree to achieve O(log n + k) per delete, where k is the number of intervals removed.

4. Address the follow-up: high-throughput stream

Discuss using an interval tree or skip list for efficient updates, and bounded memory via periodic compaction or a log-structured approach with tombstones and background merging.

5. Summarize trade-offs and test cases

Highlight trade-offs between simplicity (array) and performance (tree). Mention testing edge cases: delete before all, after all, exact match, spanning multiple, and empty delete interval.

Key Points to Mention

  • Half-open interval semantics: [start, end) to avoid ambiguity at boundaries.
  • Three overlap cases: no overlap, full overlap (delete), partial overlap (split).
  • Time complexity: O(n) for array-based single delete; O(log n + k) with balanced BST/interval tree.
  • Space complexity: O(n) for storing intervals; bounded memory requires compaction or streaming with tombstones.
  • For high-throughput: use an interval tree, skip list, or LSM-tree with background merging.
  • Edge cases: deleting an interval that exactly matches, spans multiple, or is outside the range.

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