AlgoViz

Design a URL shortener

medium 45 min

Turn a long URL into a short code and redirect anyone who opens it.

What each level should show

The same question is judged differently for mid, senior and staff.

  • Mid

    Must show

    • A working create and redirect, end to end
    • A code length from arithmetic
    • One way to make unique codes
    • A cache, with a prompt if needed

    Will be probed on

    • What happens when two codes clash
    • 301 or 302, and why
    • Which column is the key

    Stands out

    Says where the design stops being enough, with a number.

  • Senior

    Must show

    • Leads scope and targets
    • Compares at least two code schemes and picks one
    • Handles a hot link and cache expiry
    • Keeps click counting off the redirect

    Will be probed on

    • Redis failure, with the load that moves
    • Invalidation on edit and takedown
    • Why this store and this key

    Stands out

    Adds each component only after naming what forced it.

  • Staff

    Must show

    • Names the crux early and skips the routine parts
    • Treats links as a promise: durability and no reuse
    • Covers abuse, regions and cost unprompted
    • Says what not to build

    Will be probed on

    • Alias claims across regions
    • Edge logs against exact counts
    • Moving stores without breaking live links

    Stands out

    Reframes the trade-off in business terms and gives a staged rollout.

Same question, three answers

"How do you make the codes?"

LevelA good answer sounds like
Mid"A counter encoded in base62. It is unique because the number is. I would check on insert for custom aliases."
Senior"Leased ranges, so there is no call per link; scrambled, so order does not show. Random with a conditional insert is the alternative, and I would take it if links were private."
Staff"Ranges for public links, random for private. The store's conditional write is the real guarantee, so a bad lease costs a retry, not a wrong redirect. Regions hold separate ranges; only aliases need a home."