Designing a URL shortener: generating short codes and handling collisions
From the simplest way to generate codes (hash the URL and truncate) to random codes with UNIQUE, a unique ID encoded in base62 and a pre-generated key pool. Each step shows why the previous one falls short, with collision odds.
