Databricks Coding & Algorithms Interview Questions
Master your tech interview with our curated database of real questions from top companies.
Implement run-length encoding and decoding
You are given a string consisting of lowercase English letters. You need to implement run-length encoding (RLE) and its corresponding decoding. 1. Enc...
Implement a rate-limited hit counter
You are designing a hit counter that records the number of hits received in the past 5 minutes. Implement a class HitCounter with the following method...
Check if CIDR is fully canceled by rules
You are given: - A target CIDR block T as a string, e.g. "10.0.0.0/16". - A list of rule CIDR blocks. Each rule has: - A type: either "allow" or "de...
Find first CIDR block covering IP
You are given: - A single IPv4 address as a string, e.g. "192.168.1.5". - A list of CIDR blocks (IPv4), each as a string in the form "a.b.c.d/x", wher...
Implement RLE and bit-packing compression
You are asked to implement two related compression/decompression schemes: Run-Length Encoding (RLE) and bit-packing. --- Part 1 — Run-Length Encoding ...
Implement a sliding-window hit counter
Implement a hit counter that supports recordHit(timestamp) and getHits(pastSeconds). Use a fixed-size array to maintain a sliding time window (e.g., l...
Design IP/CIDR rule matcher
Design and implement a rule matcher that returns 'accept' or 'deny' for a given IPv4 address based on a set of rules. Each rule can be either an inclu...
Design BFS to detect forced win in Tic-Tac-Toe
You are given an n×n Tic-Tac-Toe–like board and a target k (1 ≤ k ≤ n). From the current board state and the player to move, design an algorithm to de...
Implement a snapshotable set with iterators
Implement a SnapshotSet data structure with the following API: add(x), remove(x), contains(x), snapshot() -> sid, and iterate(sid) -> iterator over th...
Design an efficient Tic-Tac-Toe engine
Design a Tic-Tac-Toe engine on an n x n board. Implement move(row, col, player) -> result where result indicates no winner, player1 wins, player2 wins...
Solve graph path, interval deletion, and robbery
Part A — Optimal path with transport modes: You are given a directed weighted graph of a city. Each edge has a travel time and a transport mode label ...
Design a rolling event tracker with ranges
Design a rolling event tracker that supports time-based queries. Implement a data structure with: ( 1) record(timestamp): record one event at integer ...
Design an IP filter using CIDR rules
Explain CIDR notation with a couple of concrete examples. Show how to convert a prefix like 192.168.0.0/16 into an inclusive 32-bit integer range and ...