Join waitlist
System DesignCommunity question

URL shortener in a fresher interview - what do they expect

Asked by Sid Rao 29 days ago 2 answers 8 votes

got this in a mock. I jumped straight to "use a hash" and the interviewer wanted more structure. what does a decent fresher level answer look like

2 answers

Farhan Ali29 days agoMost voted7

Roughly:
- requirements first (shorten, redirect, custom alias? expiry? how many urls?)
- API: POST to create, GET /code redirects
- code generation: base62 of an auto increment id is the simplest, hashing needs collision handling
- storage: key value is enough
- it's read heavy, so cache popular codes

Mention sharding at the end, nobody expects depth from a fresher.

Ananya Iyer28 days ago3

they also like 301 vs 302. 301 gets cached by the browser so you lose click analytics

Related questions

Go deeper

Want the full explanation, not just an answer?

Structured lessons on DSA, core CS, Java and interview skills, each ending in a quiz so you know it stuck.