Dsa
Hashing
Medium
The Ingredient Mixologist
A culinary database stores recipes as collections of ingredients and their counts. Two recipes are identical if they contain the same ingredients in the same quantities, regardless of the order they are listed. Given N recipes, count how many unique recipes are in the database.
Input Format:
- Line 1: N, the number of recipes.
- Next N lines: Each line begins with K (number of unique ingredients), followed by K pairs of 'IngredientName IngredientCount'.
Output Format:
- An integer representing the number of unique recipes.
Example:
Input:
3
2 Tomato 5 Flour 2
2 Flour 2 Tomato 5
1 Tomato 5
Output:
2
Key concepts
hashingmultisetsdictionaries
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