Question bank › Trie
Dsa Trie Medium

URL Shortener

Implement a basic URL shortener. Given a list of original URLs, return a shortened unique identifier for each. The identifiers must be unique and can consist of lowercase letters and numbers. Also, implement a lookup function so that given the identifier, you can retrieve the original URL. Ensure that the identifiers have a maximum length. Example: Input: 3 5 http://example.com http://test.com http://example.com/test Output: http://example.com -> abcde http://test.com -> abcdf http://example.com/test -> abcdg

Key concepts

trieencodingdecoding

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.