Question bank › Trie
Dsa Trie Hard

The DNA Mirror Symmetry

You are analyzing a set of genetic sequences. We define a 'Mirror Prefix' as a string S of length L such that S is a prefix of at least one sequence in your dataset, and its reverse, reverse(S), is also a prefix of at least one (possibly different) sequence in the same dataset. Write a program to find the maximum possible length L of such a Mirror Prefix. Input Format: A single line of space-separated strings. Output Format: An integer representing the maximum length L. Example: Input: apple elppa banana Output: 5 Explanation: 'apple' is a prefix of 'apple'. Its reverse 'elppa' is a prefix of 'elppa'. The length is 5. 'banana' has no reverse prefix in the set.

Key concepts

trie-searchstring-manipulation

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.