Databricks software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
'S' -- your starting location - 'D' -- your...Input: 2D grid10.0.0.1. A CIDR block is written as base_ip/k, which...Input: Listn components labeled 0 to n-1, connected by prerequisite...Input: Graph (nodes and edges)n is a binary tree defined as follows: - A tree of order 0 is a single node. - A tree of order 1 is a single node.Input: Binary treeSnapshotSet that supports adding and removing integers, membership checks, and capturing immutable snapshots of the...Input: List[start, end) (the end position is exclusive --...Input: Listn x m board where the first player to place k consecutive marks in a row, column, or diagonal...Input: Number(s)id, timestamp, workspace, user, and units. Timestamps are integer seconds and units are positive integers encoded as strings.id. Return decisions in the original input order.REQUEST_MAX: a submission may request at most 6 units.WORKSPACE_60S: a workspace may admit at most 10 units in the rolling interval (t - 60, t], including the current submission if admitted. A previous admission exactly 60 seconds old no longer counts.REQUEST_MAX followed by WORKSPACE_60S. Do not stop after the first failure.evaluate_admission(records: list[dict[str, str]]). The return type is up to the candidate; the examples use a JSON array containing id, status, and violations, where status is ACCEPTED or REJECTED and violations are rule names.{
"records": [
{"id":"a","timestamp":"0","workspace":"wA","user":"u1","units":"6"},
{"id":"b","timestamp":"10","workspace":"wA","user":"u2","units":"5"},
{"id":"c","timestamp":"20","workspace":"wA","user":"u1","units":"4"},
{"id":"d","timestamp":"60","workspace":"wA","user":"u1","units":"6"},
{"id":"e","timestamp":"61","workspace":"wB","user":"u3","units":"7"}
]
}[
{"id":"a","status":"ACCEPTED","violations":[]},
{"id":"b","status":"REJECTED","violations":["WORKSPACE_60S"]},
{"id":"c","status":"ACCEPTED","violations":[]},
{"id":"d","status":"ACCEPTED","violations":[]},
{"id":"e","status":"REJECTED","violations":["REQUEST_MAX"]}
]a uses 6 units. b would raise the workspace total to 6 + 5 = 11, exceeding 10, so it consumes nothing. c raises the total to 6 + 4 = 10. At time 60, a expires, so d produces 4 + 6 = 10. In workspace wB, e would fit the workspace limit, but its 7 units exceed the request limit of 6.Part 2 — Extensible, atomic multi-scope quotasevaluate_admission_detailed(records: list[dict[str, str]], extra_rules: list[dict[str, str]]), retaining both Part 1 rules.rule_id, scope, window_seconds, and limit. Scope is workspace or user. A user scope is the pair (workspace, user), so identically named users in different workspaces do not share capacity.W counts previously admitted units in (t - W, t] for its scope. It fails exactly when that count plus the current submission's units exceeds its limit.rule, scope, used, proposed, and limit. used is the counted admission weight before this submission and proposed = used + units.[id] and used = 0. Workspace scopes use [workspace]; user scopes use [workspace, user]. All numeric diagnostic values are JSON integers.rule_id order. Output only failed rules.{
"records": [
{"id":"a","timestamp":"0","workspace":"wA","user":"u1","units":"6"},
{"id":"b","timestamp":"10","workspace":"wA","user":"u2","units":"4"},
{"id":"c","timestamp":"60","workspace":"wA","user":"u1","units":"3"},
{"id":"d","timestamp":"61","workspace":"wA","user":"u2","units":"4"}
],
"extra_rules": [
{"rule_id":"USER_120S","scope":"user","window_seconds":"120","limit":"8"},
{"rule_id":"WORKSPACE_300S","scope":"workspace","window_seconds":"300","limit":"14"}
]
}[
{"id":"a","status":"ACCEPTED","violations":[]},
{"id":"b","status":"ACCEPTED","violations":[]},
{"id":"c","status":"REJECTED","violations":[
{"rule":"USER_120S","scope":["wA","u1"],"used":6,"proposed":9,"limit":8}
]},
{"id":"d","status":"ACCEPTED","violations":[]}
]a and b admit 6 + 4 = 10 units. For c, the 60-second count is 4, so 4 + 3 = 7 passes; its user count is 6, so 6 + 3 = 9 exceeds 8; the 300-second total would be 10 + 3 = 13, which passes. Because c is rejected, none of those counters gain 3 units. For d, the respective rolling totals become 4 + 4 = 8 for the workspace's 60-second rule, 4 + 4 = 8 for user u2, and 10 + 4 = 14 for the 300-second rule, so all pass.Example 3:{
"records": [
{"id":"a","timestamp":"0","workspace":"wA","user":"u1","units":"6"},
{"id":"b","timestamp":"1","workspace":"wA","user":"u2","units":"4"},
{"id":"c","timestamp":"60","workspace":"wA","user":"u1","units":"7"},
{"id":"d","timestamp":"120","workspace":"wA","user":"u1","units":"4"}
],
"extra_rules": [
{"rule_id":"USER_120S","scope":"user","window_seconds":"120","limit":"8"},
{"rule_id":"WORKSPACE_300S","scope":"workspace","window_seconds":"300","limit":"14"}
]
}[
{"id":"a","status":"ACCEPTED","violations":[]},
{"id":"b","status":"ACCEPTED","violations":[]},
{"id":"c","status":"REJECTED","violations":[
{"rule":"REQUEST_MAX","scope":["c"],"used":0,"proposed":7,"limit":6},
{"rule":"WORKSPACE_60S","scope":["wA"],"used":4,"proposed":11,"limit":10},
{"rule":"USER_120S","scope":["wA","u1"],"used":6,"proposed":13,"limit":8},
{"rule":"WORKSPACE_300S","scope":["wA"],"used":10,"proposed":17,"limit":14}
]},
{"id":"d","status":"ACCEPTED","violations":[]}
]a has expired only from the 60-second window. Submission c simultaneously fails the request cap, the workspace 60-second cap (4 + 7 = 11), its user cap (6 + 7 = 13), and the workspace 300-second cap (10 + 7 = 17). It consumes nothing. At time 120, both earlier admissions are outside the 60-second window, and a is exactly on the excluded boundary of u1's 120-second window. Thus d yields 0 + 4 = 4 for each of those rules and 10 + 4 = 14 for the 300-second rule, so it is accepted.Notes:"ALLOW" or "DENY".For each client address, return the action and the zero-based index of the first matching rule in input order. This is not longest-prefix matching: an earlier broad rule overrides a later, more specific rule. If no rule matches, return {"action": "DENY", "rule_index": -1}.A CIDR with prefix length p matches addresses sharing its first p bits. Normalize host bits in the supplied CIDR: for example, 203.0.113.7/24 means the same network as 203.0.113.0/24. Prefix /0 matches every IPv4 address, and /32 matches exactly one address. Network and broadcast addresses are included; they receive no special treatment.Compile the rules once, then evaluate the queries in their original order. Do not scan every rule for every query. Your solution must use at most O(N log(N + 1)) preprocessing time, O(log(N + 2)) time per query, and O(N + 1) auxiliary space for the compiled policy, where N is the number of rules. Treat IPv4 parsing and fixed-width integer operations as constant-time operations. Returning the results requires additional output space.Function or class signatureevaluate_access(rules: list[tuple[str, str]], queries: list[str]) -> list[dict[str, str | int]] — Each rule is (cidr, action); each result has exactly action and rule_index.{
"rules": [
["10.0.0.0/8", "DENY"],
["10.1.0.0/16", "ALLOW"],
["192.168.0.0/16", "ALLOW"]
],
"queries": ["10.1.2.3", "192.168.1.8", "8.8.8.8", "10.255.255.255"]
}[
{"action": "DENY", "rule_index": 0},
{"action": "ALLOW", "rule_index": 2},
{"action": "DENY", "rule_index": -1},
{"action": "DENY", "rule_index": 0}
]10.1.2.3 matches rules 0 and 1, but rule 0 appears first. The last address is included in rule 0's range. 8.8.8.8 matches no rule and is denied by default.Example 2:{
"rules": [
["255.255.255.255/32", "DENY"],
["203.0.113.7/24", "ALLOW"],
["0.0.0.0/0", "DENY"]
],
"queries": ["203.0.113.0", "203.0.113.255", "255.255.255.255", "0.0.0.0"]
}[
{"action": "ALLOW", "rule_index": 1},
{"action": "ALLOW", "rule_index": 1},
{"action": "DENY", "rule_index": 0},
{"action": "DENY", "rule_index": 2}
]203.0.113.0/24, including both endpoint addresses. The maximum IPv4 address matches rules 0 and 2, so rule 0 wins. The minimum IPv4 address matches only rule 2.Constraints:0 <= N <= 200000 rules and 0 <= Q <= 200000 queries.0 through 32."ALLOW" or "DENY"; rules may overlap or be duplicates.[0, 2^32 - 1]; an exclusive interval endpoint may equal 2^32.profits where profits[i] represents the profit of selling the ith house, you want to maximize your total profit. However, you cannot sell two consecutive houses. Implement a function that determines the maximum profit possible from the auctioning of these houses.Function/class signature: def max_profit(profits: List[int]) -> int: [2, 7, 9, 3, 1] 12 [1, 2, 3, 1] 4 0 <= profits.length <= 100 profits must be non-negative integers and less than 1000.nums and an integer target. Write a function to find two numbers in nums such that they add up to target. Return their indices as an array. Each input would be such that exactly one solution exists, and you may not use the same element twice.def two_sum(nums: List[int], target: int) -> List[int]:nums = [2, 7, 11, 15], target = 9 [0, 1] nums[0] + nums[1] = 2 + 7 = 9.nums = [3, 2, 4], target = 6 [1, 2] nums[1] + nums[2] = 2 + 4 = 6.nums and an integer k, return the maximum sliding window for each window of size k. The output should be an array of the maximum values from each sliding window.def max_sliding_window(nums: List[int], k: int) -> List[int]: nums = [1,3,-1,-3,5,3,6,7], k = 3 [3, 3, 5, 5, 6, 7] [3], [3], [5], [5], [6], and [7]. nums = [1], k = 1 [1] 1 <= nums.length <= 10^5 -10^4 <= nums[i] <= 10^4 1 <= k <= nums.length void processOrder(Order order) and return a list of confirmed orders.class Order: def __init__(self, order_id: int, stock_symbol: str, quantity: int, timestamp: int): def processOrder(self, order: Order) -> List[Order]: Order(1, "AAPL", 10, 100) Confirmed Order: Order(1, "AAPL", 10, 100) Order(2, "GOOG", 5, 50) (expired order is not processed) [] 0 < order_id <= 10^6 0 < quantity <= 1000 timestamp is a positive integer designating the order time.prices representing the prices of a stock on different days, return the maximum profit you can achieve. def max_profit(prices: List[int]) -> int:prices = [7, 1, 5, 3, 6, 4] 7 prices = [1, 2, 3, 4, 5] 4 -1.def shortest_path(graph: Dict[int, List[Tuple[int, int]]], start: int, destination: int) -> Union[int, List[int]]:graph = {0: [(1, 4), (2, 2)], 1: [(3, 1)], 2: [(1, 1), (3, 5)], 3: []}, start = 0, destination = 3 5 0 -> 2 -> 1 -> 3, which has a total weight of 5.Example 2: graph = {0: [(1, 4), (2, 1)], 1: [(3, 1)], 2: [(1, 2), (3, 5)], 3: []}, start = 0, destination = 1 4 Constraints: 1 <= len(graph) <= 100. 10^3. prices where prices[i] is the price of a stock on the i-th day, you can complete as many transactions as you like (i.e., buy and sell multiple times) but you must sell the stock before you buy it again. Your goal is to calculate the maximum profit you can achieve. def maxProfit(prices: List[int]) -> int: prices = [7, 1, 5, 3, 6, 4] 7 prices = [1, 2, 3, 4, 5] 4 0 <= prices.length <= 30000 0 <= prices[i] <= 10^4Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free