Question bank › Trie
Dsa Trie Hard

Longest Common Prefix in Words

You are given a list of words and need to find the longest common prefix among them using a trie. Input format: The first line contains an integer n (1 ≤ n ≤ 1000) representing the number of words. The next n lines each contain a single word (1 ≤ length of word ≤ 100). Output format: Print the longest common prefix. If there is no common prefix, print an empty string. Example: Input: 4 flower flow flight light Output: fl

Key concepts

triecommon prefixstring comparison

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.