educative.io

Educative

Paste bin url - 68 billion keys

Can someone explain why we are doing 64^6 to get 68 billion unique keys? How does this work?

I think the hint to this answer is here in the previous “URL Shortening” question (Refer to the section 6.a. Encoding actual URL section)

Long story short, I believe they decided to go for 6 letters (64 ^ 6 ~ 68.7 billion Unique strings) since that is the minimum letters required to represent at least 3.6 billion bin urls (unique string for each stored bin) for 10 years.

If you use 4 letters (64 ^ 4 ~ 16.7 million) and 5 letters (64 ^ 5 ~ 1.07 billion), those won’t be enough to represent the minimum 3.6 billion bin urls.