#13MediumDesign· ID Generation and Base62 Encoding
Design a URL Shortener
Input format
urls: array of URL strings
Output format
Array of booleans, one per URL, true when the round trip returns the original URL
Examples
Input: urls = ["https://example.com/docs/getting-started"]
Output: [true]
The URL receives the code for ID 1 and decodes back to itself.
Input: urls = ["https://example.net/same", "https://example.net/same"]
Output: [true, true]
Encoding the same URL twice returns the same short URL, and both decode correctly.
Constraints
- 1 <= urls.length <= 10^4
- 1 <= urls[i].length <= 10^4
- Each URL is a valid absolute URL.
- Short codes must use only base62 characters.
Study first
- #design
- #hash-table
- #base62
- #url-shortener
