Question bank › Trie
Dsa Trie Medium

Product Code Validator

You are developing a system to validate product codes. Each product code is unique and follows a specific structure. Given a list of valid product codes and a code to validate, print 'Valid' if the code is found in the list, otherwise print 'Invalid'. Additionally, if the code is too short or too long compared to the average length of valid codes, return 'Length Invalid'. Input Format: - The first line contains an integer n (1 ≤ n ≤ 10^4), the number of valid product codes. - The next n lines each contain a valid product code (length ≤ 100). - The last line contains the product code to validate. Output Format: - Print 'Valid', 'Invalid' or 'Length Invalid' as per the conditions above. Example: Input: 3 AB12CD XYZ34EF 1234GH XY12 Output: Invalid

Key concepts

trievalidationstrings

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.