Question
Why is using the first few characters of the long URL as the short code a bad approach?
A
Because many URLs can share the same prefix and cause collisions
B
Because prefix-based codes are always too long
C
Because it cannot support HTTP 302 redirects
D
Because database indexes do not work on prefix strings
Explanation
Many URLs can share the same prefix, causing collisions.
Taking the first N characters of a long URL does not provide enough uniqueness. Many URLs from the same domain can start with the same prefix. If two long URLs produce the same short code, the system cannot know which original URL to redirect to. This breaks the core correctness requirement.