mediumOpen-ended · your tools60 min Premium
LinkLock
A URL shortener with custom slugs, expiry, and click analytics, data structure design under constraints.
Data StructuresString / Parsing
Problem
A greenfield build: a URL shortener with guardrails. Clone the starter repo, use your own editor and AI tools, and build under a 60-minute timer.
The spec
shorten(url, custom?)→ a slug. With no custom slug, generate one (short, collision-safe). Custom slugs must be unique and validated (charset, length).resolve(slug)→ the original URL, rejecting unknown or expired slugs.- Links can have a TTL (expiry). After expiry, resolution fails.
- Every resolution increments a click count. Provide
topLinks(n)— the n most-clicked links.
What interviewers watch
- The slug scheme: how do you avoid collisions without unbounded length?
- The lookup structure: is resolution O(1)-ish, and is expiry checked without scanning all links?
- Do you decide the composition (map + sorted expiry structure) before prompting the AI?
- Analytics semantics: do clicks on expired links count?
Submission
Export your code and AI chat transcript, note tools and time, and submit for a verdict.
Deliverables
- Shorten a URL with an optional custom slug; generate a slug when absent
- Resolve a slug to the URL; reject unknown or expired slugs
- Optional expiry (TTL) per link
- Click counts per link; a top-N endpoint
- Tests for collisions, expiry, and analytics