Dsa
Hashing
Warm-up
Count Unique Ingredients
You are given a list of ingredients used in various recipes. Your task is to count how many unique ingredients are present in this list and return that count.
Input format:
- The first line contains an integer N (1 ≤ N ≤ 1000), the number of ingredients.
- The next N lines each contain a string, the name of the ingredient.
Output format:
- A single integer representing the count of unique ingredients.
Example Input:
5
flour
sugar
eggs
sugar
milk
Example Output:
4
Key concepts
hashingcountinglists
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