Question bank › Hashing
Dsa Hashing Easy

Ingredient Pair Finder

You are tasked with finding pairs of ingredients that together form a specified target weight. Given a list of ingredient weights and the target weight, determine how many unique pairs can be formed. Each pair (i,j) where i<j counts as one unique solution. If the same weight appears multiple times, it can be used more than once in pairs. Input format: The first line contains an integer N (1 ≤ N ≤ 2000), the number of ingredients. The second line contains N space-separated integers representing the weights of the ingredients. The third line contains the target weight. Output format: An integer representing the number of unique pairs that sum to the target weight. Example: Input: 5 1 2 3 4 3 6 Output: 2

Key concepts

hashingarrayspairs

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.