Dsa
Two Pointers
Easy
Trendy Pairs
You are given a list of students' names and their fashion scores represented as a two-dimensional array. You want to find all pairs of students with different names where the absolute difference in their score is equal to a given target score.
Input:
- The first line contains an integer n (1 <= n <= 100) - the number of students.
- The next n lines contain a student name (a string) and a fashion score (an integer), where the fashion score is unique for each student. The last line contains the target score.
Output:
- Output the number of unique pairs of names and scores that have the absolute difference equal to the target.
Example:
Input:
3
Alice 10
Bob 12
Charlie 14
2
Output:
1
The pair is (Alice, Bob).
Key concepts
two_pointersstringtwo_dimensional_array
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