Google Interview Question
Software Engineer / DevelopersCountry: United States
Interview Type: In-Person
The formulation of the question is probably wrong; "Design a URL shortener" seems more like it.
There is a Stack Overflow thread, titled "How to code a URL shortener?". which goes into the gritty details. Unfortunately, links can't be used here, but check it out through Google.
Store full URLs in a database table. To get the shortened form, just get, say, the base 62 version of the ID of the URL's row in the table (62 = ten digits, 26 lowercase characters, 26 uppercase characters). The service itself would issue HTTP 302 redirects to avoid putting its own shortened link into the browser's history.
- nilkn January 20, 2014