Dsa
Trie
Hard
Product Name Classifier
Your task is to classify a list of product names into categories based on a given taxonomy. Each category has defined keywords that products must contain to be classified under that category. Implement a function that determines the category of each product. If a product contains keywords from multiple categories, return the highest priority category (based on the input order). Input consists of categories (followed by their keywords) and a list of product names. Output should be a newline-separated list of classified categories for each product.
Example:
Input:
Electronics
phone
computer
Toys
ball
phone case
computer mouse
soccer ball
Output:
Electronics
Electronics
Toys
Key concepts
trieclassificationtaxonomies
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