Problem
Submissions

Problem: Count Pairs Whose Sum is Less than Target

Statement

You are given a 0-indexed integer array, nums, of length nn, and an integer target. Your task is to determine the number of distinct pairs of indexes (i,j)(i, j) such that:

  • 0≤i<j<n0 \leq i < j < n (i.e., ii comes before jj in the array)

  • The sum of the elements of the indexes (i,j)(i, j), (i.e., nums[i]+nums[j]\text{nums}[i] + \text{nums}[j]), is strictly less than the target.

Constraints:

  • n=n = nums.length

  • 1≤n≤501 \leq n\leq 50

  • −50≤-50 \leq nums[i], target ≤50\leq 50

Problem
Submissions

Problem: Count Pairs Whose Sum is Less than Target

Statement

You are given a 0-indexed integer array, nums, of length nn, and an integer target. Your task is to determine the number of distinct pairs of indexes (i,j)(i, j) such that:

  • 0≤i<j<n0 \leq i < j < n (i.e., ii comes before jj in the array)

  • The sum of the elements of the indexes (i,j)(i, j), (i.e., nums[i]+nums[j]\text{nums}[i] + \text{nums}[j]), is strictly less than the target.

Constraints:

  • n=n = nums.length

  • 1≤n≤501 \leq n\leq 50

  • −50≤-50 \leq nums[i], target ≤50\leq 50