Tap here to switch tabs
Problem
Submissions

Problem: Number of Pairs Satisfying Inequality

Try to solve the Number of Pairs Satisfying Inequality problem.

Statement

Given two integer arrays nums1 and nums2, each of length n, and an integer diff, determine the number of index pairs (i,j)(i, j) that satisfy the following conditions:

  • 0≤i<j<n0 \leq i < j < n

  • nums1[i] - nums1[j] ≤\leq nums2[i] - nums2[j] + diff

Return the total count of such valid pairs.

Constraints:

  • n == nums1.length == nums2.length

  • 2≤2 \leq n ≤105\leq 10^5

  • −104≤-10^4 \leq nums1[i], nums2[i] ≤104\leq 10^4

  • −104≤-10^4 \leq diff ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Pairs Satisfying Inequality

Try to solve the Number of Pairs Satisfying Inequality problem.

Statement

Given two integer arrays nums1 and nums2, each of length n, and an integer diff, determine the number of index pairs (i,j)(i, j) that satisfy the following conditions:

  • 0≤i<j<n0 \leq i < j < n

  • nums1[i] - nums1[j] ≤\leq nums2[i] - nums2[j] + diff

Return the total count of such valid pairs.

Constraints:

  • n == nums1.length == nums2.length

  • 2≤2 \leq n ≤105\leq 10^5

  • −104≤-10^4 \leq nums1[i], nums2[i] ≤104\leq 10^4

  • −104≤-10^4 \leq diff ≤104\leq 10^4