Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Fair Pairs

Count the Number of Fair Pairs asks you to count pairs of distinct indices in an integer array, with the first before the second, whose values sum to a number within inclusive lower and upper bounds.

Statement

Given an integer array nums and two integers lower and upper, count how many index pairs (i, j) satisfy all of the following:
the indices are distinct with i < j, and the sum nums[i] + nums[j] lies within the inclusive range from lower to upper.

Return the total number of such pairs.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums.length ==== n

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

  • −109≤-10^9 \leq lower ≤\leq upper ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count the Number of Fair Pairs

Count the Number of Fair Pairs asks you to count pairs of distinct indices in an integer array, with the first before the second, whose values sum to a number within inclusive lower and upper bounds.

Statement

Given an integer array nums and two integers lower and upper, count how many index pairs (i, j) satisfy all of the following:
the indices are distinct with i < j, and the sum nums[i] + nums[j] lies within the inclusive range from lower to upper.

Return the total number of such pairs.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • nums.length ==== n

  • −109≤-10^9 \leq nums[i] ≤109\leq 10^9

  • −109≤-10^9 \leq lower ≤\leq upper ≤109\leq 10^9