Pergunta de entrevista da empresa Amazon

How can design a TinyURL for a website? Design an algorithm and write sample code which generates TinyURL for a website.

Respostas da entrevista

Sigiloso

7 de ago. de 2013

Take the URL and run it through a hash algorithm like md5 that can take arbitrary length input string and convert it to a fixed length hash value. Append the hash value to tinyurl like "http://tinyurl.com/".

2

Sigiloso

7 de ago. de 2013

And you'll obviously need to make sure your webserver then expands the "http://tinyurl,com/" to the full URL by looking up some database.