Coding interview exercises
Coding interview exercises
Sign in to see your remaining sessions and start a practice run.
Five minutes, start to finish: reading the task, asking the interviewer, running tests, fixing two bugs and the questions at the end. Prefer to read? The same steps, written out.
A teacher tracks each student's scores across several assignments during a term. At any point they want to know a student's average and letter grade, and pull class-wide reports like the honor roll or who's failing.
A parking garage charges vehicles for how long they stay. Different vehicle types are billed completely differently.
A fleet of buses streams position reports back to a control center. Each bus follows a fixed plan: an ordered list of stations it must visit, in order. The control center needs to answer, at any moment: where is each bus right now, and what's the next station it's heading to (or has it finished its whole route)?
An internal system stores a tree of files and directories. Every node can have an explicit permission level, or it can be left unset - in that case it inherits the permission of its nearest ancestor that does have one. The root always has an explicit permission.
src/ratelimiter.py implements a sliding-window rate limiter: each user is allowed maxrequests within any trailing window_seconds window.
A commercial building has environmental sensors scattered across its floors, each sensing one specific thing where it's mounted - and more sensor types may be added later. Every sensor reports its reading as a single number:
Our API gateway uses a small in-house load balancer (src/) to spread traffic across a pool of backend servers. It supports three routing strategies (RoundRobin, WeightedRoundRobin, LeastConnections), retries failed requests on another backend, and runs health checks.
Users can receive notifications through several channels - email, SMS, an Android push notification, and more may be added later. Each user picks exactly one preferred channel.
A supermarket checkout scans products one at a time. Each product has a base price, but some products are on promotion. You need to build a system that tracks scanned products and returns the current cart price at any point.