Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Implement an in-memory database with TTL and backup
In-Memory Database (Levels 1–4: TTL and Backup/Restore) Implement an in-memory database that stores records identified by a string key. Each record co...
Implement an in-memory SQL-like table
Problem Implement a simple in-memory database for one table. All values are strings. Each row is identified by a rowKey (string). Each row contains co...
Implement credit ledger with out-of-order timestamps
Problem You are implementing a GPU credit ledger that supports adding credits, charging credits, and querying balances. Requests can arrive in any tim...
Implement multi-level task manager APIs
You are implementing an in-memory task management system with a set of APIs that evolve over 4 levels. All APIs receive a timestamp: int parameter. Un...
Implement toy-language types and generic substitution
Problem: Toy Language Type System (Printing + Generic Resolution) You are implementing a small type system for a custom “Toy Language”. Types can be: ...
Dedupe titles in per-shelf viewport
You are rendering a streaming app home page. - The home page consists of shelves displayed from top to bottom. - Each shelf contains a list of titleId...
Implement a memory allocator with malloc/free
Problem You are implementing a simplified memory allocator over a contiguous memory region. Initialize the allocator with a fixed total size: - alloca...
Find path in implicit Fibonacci tree
You are given a special family of binary trees called Fibonacci trees. The k‑th order Fibonacci tree T(k) is defined recursively: - T(1) is a single n...
Simulate turn-based monster team battle
Design an object-oriented model and implement the core battle logic for a turn-based fight between two teams of monsters. The system should simulate t...
Count business days excluding holidays
Problem: Count Working Days Between Two Dates Given a start date, an end date (inclusive), and a set of holiday dates, compute the number of working d...
Implement cursor-based query pagination
You are building a small in-memory database that stores rows with the following fields: - id (string, unique) - score (integer) - payload (string) You...
Implement staircase printing and distributed mode/median
Problem A: Print a “staircase” pattern Implement a function that prints a staircase with n rows. Input - An integer n (n >= 1) Output - Print n lines....
Find earliest time all riders become connected
You are given activity logs for a ride-sharing app. Each log entry indicates that two riders shared a ride at a certain time, which creates an undirec...
Compute courier pay and implement load balancing
Problem 1: Compute courier (delivery driver) pay You are given a sequence of delivery-related events for a courier during a day. Your task is to compu...
Implement undo/redo with two stacks
Problem: Undo/Redo for a Simple Text Editor Design a data structure that simulates a very small text editor with undo and redo. You are given a sequen...
Compute time to infect all cells
You are given an n × m grid representing people in a city. - Each cell is either infected (1) or healthy (0). - Two cells are neighbors if they share ...
Implement streaming RLE and bit-packed codec
You are implementing a simple compression scheme for sequences of 32‑bit signed integers. The codec should support two encoding strategies: 1. Run‑Len...
Join tables to map userId to name
Problem You are given three tables represented as 2D string arrays (each row is a record, no headers). You need to produce a mapping from userId → cus...
Solve matrix groups and recipe inventory
Problem 1: Find the smallest 3×3 group in a matrix You are given an m × n 2D integer array grid. - Partition the grid into non-overlapping 3×3 blocks,...
Implement a persistent sharded key-value store
Problem Implement a simple key–value store that persists data on disk. You must store the data in fixed-size shards, where each shard is saved in one ...