vefallstar.blogg.se

System design interview tinyurl
System design interview tinyurl















To help you understand what is base 62 encoding, let me show you an example: We can then do base 62 encoding and return the short URL. That way it’s going to be unique as we don’t reuse the same integer. The counter keeps incrementing every time a new request is received.

system design interview tinyurl

The first solution that comes to mind is using a counter.

#System design interview tinyurl how to

That depends on how many short URLs you expect to create/ store.Ĭoming back to the question of how to design the short URL – You can discuss if the range is good enough for the system you are designing.

system design interview tinyurl

If your short URL is 7 characters long, then you have 62^7 unique combinations possible. It’s perfectly acceptable to mention here that you can look it up on Wiki/ StackOverflow or the actual RFC for the list of acceptable characters in a URL.įor simplicity, let’s stick to 26 small characters, 26 capital characters and 10 digits. These reserved characters cannot be used in your generated short URL because they are interpreted differently. And lastly there are certain reserved characters like question mark (?), forward slash (/), etc. And there are certain special characters which are not allowed like space ( ), backslash (\), etc. If yes, what all characters make sense? In the real world, there are certain characters which are allowed like dash (-), dot (.), etc. You can discuss about special characters to be included or not. The acceptable characters for a URL are small a to z, capital A to Z and digits 0 to 9. The first question that arises here is: what all are the acceptable characters in the generated short URL? So, let’s look at the core functionality first… The focus should be on two things: the core functionalities and scalability. You need to understand that these are secondary or extraneous features. You can have extra features like user can pick the short URL or the short URLs expire after some time. Ii) Given a short URL -> return the corresponding long URL I) Given a long URL -> generate a short URL and return it I think it makes more sense here to just design a service/ API with two main endpoints: To begin with, you can ask if you are designing a web page or just an API. You can even discuss similar pre-existing systems like bit.ly, tinyURL, etc.

system design interview tinyurl

As a candidate, you need to ask lots of questions and have a good discussion about various approaches that you can take. Since it’s a system design question, it’s very open ended. Let’s find out how to answer this question in a technical interview.















System design interview tinyurl