Question bank › Two Pointers
Dsa Two Pointers Easy

Unique Pair Count

You are given a sorted array of integers. Your task is to count the number of unique pairs (i, j) such that i < j and nums[i] + nums[j] = target. Each pair (i, j) must be counted only once regardless of their order. Input: - The first line contains an integer n (1 <= n <= 1000) - the length of the array. - The second line contains n unique integers nums[i] sorted in non-decreasing order. - The third line contains an integer target. Output: - Return the count of unique pairs that sum up to the target. Example: Input: 5 1 2 3 4 5 6 Output: 2 The pairs are (1, 5) and (2, 4).

Key concepts

two_pointerssortarray

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 InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.