DevsUnite

Databricks Interview Questions

27 real coding interview questions recently asked at Databricks, spanning Algorithms and Design and Concurrency (Dedicated Round), with a real difficulty tag and a direct LeetCode link for every question.

By DevsUnite · 27 Problems

Total Problems: 27Difficulty Levels:EasyMediumHard

Loading your progress…0/27
Capacity To Ship Packages Within D Days
LeetCodeMedium

A binary-search-on-the-answer problem: instead of searching over indices, you binary search over possible ship capacities and use a greedy simulation to check whether a given capacity can ship all packages within D days. It tests whether a candidate recognizes a monotonic feasibility condition (larger capacity always ships in fewer-or-equal days) and can pair binary search with a linear-time greedy checker. This "binary search on answer" pattern shows up repeatedly across interview problems, so it's often used as a signal for pattern transfer, not just this specific problem.

Trapping Rain Water
LeetCodeHard

Given an elevation map, compute how much water it can trap after rain — the water trapped at each index equals the shorter of the tallest bars to its left and right, minus its own height. It's solvable with two pointers in O(1) extra space, with a monotonic stack, or with two precomputed max-prefix/max-suffix arrays, making it a great vehicle for comparing multiple valid techniques in one interview. Its breadth of companies asking it reflects that it's one of the most widely used checks of two-pointer/array reasoning in the entire interview circuit.

Max Stack
LeetCodeHard

A design problem asking for a stack that supports push, pop, top, peekMax, and popMax — the difficulty is popMax, which must remove the maximum element from anywhere in the stack while preserving relative order of the rest. Efficient solutions typically pair a doubly linked list (for O(1) removal from the middle) with an ordered map or balanced structure keyed by value to locate the max quickly. It's a strong test of composing multiple data structures to hit better-than-O(n) time on every operation, not just the easy ones.

All O'one Data Structure
LeetCodeHard

This design problem requires inc(key), dec(key), getMaxKey(), and getMinKey() to all run in O(1) — ruling out a plain hashmap plus heap, since heaps don't give O(1) max/min removal alongside arbitrary key updates. The standard solution buckets keys by their current count in a doubly linked list of count-buckets, combined with a hashmap from key to its bucket, so incrementing or decrementing a key just moves it to an adjacent bucket. It's a genuinely hard composition of a hash map with a linked structure, and a strong signal for whether a candidate can design toward a strict complexity bound rather than a merely-workable one.

Word Break
LeetCodeMedium

Given a string and a dictionary of words, this asks whether the string can be segmented into a space-separated sequence of dictionary words. The standard solution is DP where dp[i] indicates whether the prefix of length i can be segmented, checking all dictionary words as potential suffixes ending at each position. It's a foundational string-DP problem and often a stepping stone to the harder Word Break II, testing whether a candidate can define and fill a boolean DP array correctly.

Rotting Oranges
LeetCodeMedium

This is a multi-source BFS problem: all initially rotten oranges are enqueued simultaneously, and the grid is processed level by level to find the minimum number of minutes until no fresh orange remains (or -1 if some are unreachable). It tests whether a candidate can generalize single-source BFS to multiple simultaneous sources and correctly track elapsed time via BFS levels rather than per-cell distance tracking. A common trap is starting BFS from a single source or forgetting to check for oranges that can never rot.

All Nodes Distance K in Binary Tree
LeetCodeMedium

Binary trees only have parent-to-child pointers, but this problem needs distance-k neighbors in every direction, so the standard trick is to first do a pass adding parent pointers (or building an adjacency map), converting the tree into an undirected graph. From there it's a straightforward BFS from the target node up to depth k. It tests whether a candidate can recognize that a tree-shaped input sometimes needs to be reframed as a general graph before the right algorithm applies.

Decode String
LeetCodeMedium

A stack-based string-processing problem: decode a nested, run-length-encoded string like "3[a2[c]]" into its expanded form, where the nesting can go arbitrarily deep. The standard approach pushes the current string and repeat count onto a stack whenever a '[' is seen and pops/multiplies/concatenates on ']'. It's a clean test of stack-based parsing and correctly handling nested state, which is exactly why it's used across companies as a string-processing check.

K Closest Points to Origin
LeetCodeMedium

A classic "top-k" selection problem: find the k points closest to the origin out of a larger set. It can be solved with a max-heap of size k (evict the farthest point whenever a closer one is found) for an O(n log k) solution, or with a quickselect-style partition for expected O(n). It's commonly used to see whether a candidate defaults to sorting everything (O(n log n)) or recognizes the more efficient heap/quickselect approaches suited to "top-k" style questions.

Asteroid Collision
LeetCodeMedium

A stack-simulation problem: asteroids move left or right, and colliding pairs are resolved by comparing sizes and directions according to a small set of rules. The stack holds asteroids that haven't yet been destroyed, and each new asteroid may trigger a cascade of comparisons against the stack top before it's pushed or discarded. It's a good test of careful, exhaustive case enumeration (which asteroid survives, ties, same-direction pairs) rather than algorithmic complexity.

Design Hit Counter
LeetCodeMedium

This design problem asks for a counter that records hits with timestamps and can report the number of hits in the past 300 seconds. It's typically implemented with a queue (or a fixed-size circular buffer of timestamp/count pairs) that evicts entries falling outside the trailing time window as new hits arrive. It tests whether a candidate can design a data structure for a sliding time window under both single-hit and (in a common follow-up) batched-hit conditions.

Time Based Key-Value Store
LeetCodeMedium

A design problem requiring a hash map from key to a list of (timestamp, value) pairs, plus binary search to efficiently find the value at or before a queried timestamp. It tests whether a candidate can combine a hash map with binary search rather than resorting to a linear scan, since values are appended with strictly increasing timestamps. It's a natural fit for companies dealing with versioned or time-stamped storage — Anthropic and OpenAI probe it in the context of retrieving the right version of a model checkpoint by timestamp, a real pattern in ML infrastructure.

Snapshot Array
LeetCodeMedium

A design problem: build an array that supports taking cheap snapshots and later querying the value of any index at any past snapshot, without paying the cost of copying the whole array on every snap(). The efficient solution stores, per index, a sparse list of (snap_id, value) pairs and binary-searches that list on get() rather than materializing full array copies — the model-state-checkpointing framing (as noted in this problem's source context) maps directly onto this pattern, since checkpointing large state cheaply and querying it later by version is the same underlying need. It tests whether a candidate reaches for a lazy, per-index versioning scheme instead of a naive full-copy snapshot.

Find All Anagrams in a String
LeetCodeMedium

A fixed-size sliding window problem: find all starting indices where a substring of the given string is an anagram of a pattern. The efficient approach maintains a running character-frequency count for the current window and compares it against the pattern's frequency count as the window slides one character at a time, avoiding recomputation from scratch. It's a common early-stage filter for whether a candidate can maintain incremental window state (add one char, remove one char) instead of re-scanning each window.

Cheapest Flights Within K Stops
LeetCodeMedium

A shortest-path problem with an added constraint on the number of edges (stops) used: the standard approaches are a bounded Bellman-Ford (relax all edges K+1 times) or a modified Dijkstra/BFS that tracks both cost and stop count as part of the search state. It tests whether a candidate understands why plain Dijkstra can fail here (it doesn't account for the stop limit) and can adapt a shortest-path algorithm to a secondary constraint — a pattern that generalizes to real routing and logistics problems.

IP to CIDR
LeetCodeMedium

Given a starting IP address and a count of addresses to cover, the task is to output the minimum number of CIDR blocks that exactly cover that range. The approach converts the IP to a 32-bit integer, then repeatedly takes the largest power-of-two-aligned block starting at the current address that doesn't overshoot the remaining count, subtracting it and continuing. It's a bit-manipulation problem dressed in networking terminology, testing comfort with binary representations and address alignment rather than networking domain knowledge itself.

Max Area of Island
LeetCodeMedium

A grid flood-fill problem: for each unvisited land cell, run DFS or BFS to measure the connected island's size and track the maximum across all islands. It's a direct, well-known application of grid traversal with visited-tracking, generally used as an accessible warm-up to confirm a candidate can implement flood fill cleanly (including edge and boundary handling) before moving to a harder graph or DP follow-up.

House Robber II
LeetCodeMedium

An extension of the classic House Robber DP where houses are arranged in a circle, so the first and last house can't both be robbed. The standard solution runs the original linear DP twice — once excluding the first house, once excluding the last — and takes the max of the two results. It's a good test of recognizing how a small structural change (circular vs. linear) can be handled by decomposing into two instances of a known subproblem rather than inventing new DP state.

Design Tic-Tac-Toe
LeetCodeMedium

This is a design problem: implement a Tic-Tac-Toe board that reports a winner in O(1) per move instead of rescanning the whole board after every play. The standard trick is maintaining running counters per row, per column, and for each diagonal, incrementing or decrementing them per player's move so a win can be detected by checking whether any counter hits the board size. It's a solid signal for whether a candidate can convert an O(n) check into an O(1) amortized one by choosing the right incremental state.

Top K Frequent Words
LeetCodeMedium

Given a list of words, return the k most frequent ones, with ties broken by lexicographic order. It combines a frequency hash map with either a heap using a custom comparator for the tie-breaking rule, or a bucket-sort-by-frequency approach for an O(n) alternative. The tie-breaking requirement is the real trap — many otherwise-correct solutions get the right frequencies but the wrong order among equally-frequent words, making this a good test of attention to problem-statement detail, not just knowledge of heaps.

LRU Cache
LeetCodeMedium

A design problem requiring O(1) get and put operations with least-recently-used eviction, implemented by combining a hash map (for O(1) lookup) with a doubly linked list (for O(1) reordering and eviction from either end). This exact structure underlies real inference key-value caches — it's reportedly one of the most frequently asked design questions at companies building LLM inference systems, since eviction policy for a bounded cache maps directly onto managing GPU memory for attention KV caches. It's a strong test of whether a candidate can compose two data structures to get O(1) across every required operation, not just some of them.

Binary Search Tree Iterator
LeetCodeMedium

A design problem: implement an iterator over a BST's in-order traversal with next() and hasNext(), where next() should run in average O(1) time and the iterator should use O(h) extra memory rather than flattening the whole tree upfront. The standard solution uses an explicit stack that's incrementally pushed further down the left spine as needed, simulating in-order traversal lazily. It tests whether a candidate can convert a typically-recursive traversal into an iterative, resumable one under a real memory constraint.

Log in to save your progress, favorites, and notes to your account.

Frequently asked questions

What coding interview questions does Databricks ask?

This page tracks 27 real, recently reported Databricks coding interview questions, organized by topic: Algorithms and Design and Concurrency (Dedicated Round).

How many Databricks interview questions are on this list?

27 questions in total: 1 Easy, 23 Medium, and 3 Hard, each linked to its real LeetCode problem page.

Is it free to use?

Yes. Browsing every problem on this page is completely free, with no account required. Creating a free DevsUnite account lets you save your checked-off progress, star favorites, and add personal notes that sync across devices.

Do I need an account to track my progress?

You can read and solve every problem without logging in. An account is only required to mark a problem as done, star it, or add a note. Those actions save to your account instead of resetting on refresh.