Question bank › Trie
Dsa Trie Hard

Longest Unique Prefix Finder

Given a list of words, implement a function that finds the longest unique prefix for each word that differentiates it from all other words. A prefix is unique if it's not a prefix of any other word in the list. If no unique prefix exists for a word, return an empty string for it. Input is given as a newline-separated list of words. Output should be a newline-separated list of longest unique prefixes corresponding to the input words. Example: Input: apple ape bat batman grapes Output: app bat batm g

Key concepts

triestringsprefixes

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.