Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Pairs With Absolute Difference K

Count Number of Pairs With Absolute Difference K asks you to count index pairs in an array whose values differ by exactly k, counting each pair only when its first index comes earlier.

Statement

Given an integer array nums and an integer k, return the number of index pairs (i, j) such that i << j and the absolute difference between nums[i] and nums[j] equals k.

Constraints:

  • 1≤1 \leq nums.length ≤200\leq 200

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq k ≤99\leq 99

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Number of Pairs With Absolute Difference K

Count Number of Pairs With Absolute Difference K asks you to count index pairs in an array whose values differ by exactly k, counting each pair only when its first index comes earlier.

Statement

Given an integer array nums and an integer k, return the number of index pairs (i, j) such that i << j and the absolute difference between nums[i] and nums[j] equals k.

Constraints:

  • 1≤1 \leq nums.length ≤200\leq 200

  • 1≤1 \leq nums[i] ≤100\leq 100

  • 1≤1 \leq k ≤99\leq 99