Try
↑ ↓ move↵ openesc close

Interview prep / URL shortener

Mid · URL shortener · System design interview question

What are the strengths and weaknesses of making a code by hashing the long address?

Sketch your own answer first, then compare it with the one below.

A strong answer

The same address always gives the same code, so duplicates are free and no coordination is needed.

Two different addresses can share a short prefix of the hash, so collisions still need a check and a re-hash with a salt. The scheme also cannot give two users separate links to one address unless the user is part of the hash input. A secure hash does not help guessability if the code is short.

Sources

Learn it by running it

The design a url shortener lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms