Dsa
Prefix Sum
Warm-up
Balanced Team Skills
You are organizing a project team. Each member has a skill level represented by an integer in an array. You want to find how many pairs of members have a skill level that sums to a specific target level. Write a program that reads the number of members and their skill levels, followed by the target sum. Output the total number of pairs that sum to the target. For example, given the input:
5
1 2 3 4 5
5
You should output:
2
This is because the pairs (2, 3) and (1, 4) both sum to 5.
Key concepts
prefix_sumarrayscumulative_sum
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