TGViewer
Coding Projects Coding Projects @programming_experts · 67.9K subscribers
Post #2799 2.46K
An LRU Cache removes the item that has not been used for the longest time when the cache reaches its capacity.

A common implementation uses:

• Hash Map for O(1) lookup.

• Doubly Linked List for O(1) insertion and removal.

Time Complexity:

• Get: O(1)

• Put: O(1)

2️⃣0️⃣0️⃣ How Would You Design a URL Shortener?

Answer:

A URL shortener converts a long URL into a short, unique URL.

Example:

Long URL: https://example.com/products/category/item/12345

Short URL: https://short.ly/aB92x

A basic system can use:

1. Generate a unique ID for each URL.

2. Convert the ID into a short Base62 string.

3. Store the mapping between the short code and original URL.

4. When the short URL is requested, look up the original URL.

5. Redirect the user to the original URL.

Important Design Considerations:

• Unique short IDs

• Database design

• Caching

• Scalability

• High availability

• Expiration of URLs

• Analytics and click tracking

🔥 Double Tap ❤️ For More
  • ❤ 2
More from @programming_experts
  1. Oct 7, 2026𝗠𝗮𝘀𝘁𝗲𝗿 𝗣𝗼𝘄𝗲𝗿 𝗕𝗜 𝗳𝗼𝗿 𝗙𝗥𝗘𝗘! 🔥 Learn Power BI through these FREE learnin…
  2. Sep 29, 2026Post #2901
  3. Sep 29, 2026Post #2900
  4. Sep 29, 2026Post #2899
  5. Sep 29, 2026What will be the output? x = 10 if x > 5 and x < 10: print("Yes") else: print("No") A) Yes…
  6. Sep 29, 2026Post #2897
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →