Count Pairs With Difference
Medium · rating 1400 · Hashing, Arrays
The first line contains n and k. The second line has n integers. Print the number of index pairs (i, j) with i < j and |ai - aj| = k.
Constraints: 1 ≤ n ≤ 105, 0 ≤ k ≤ 109
Related problems
- Count Pairs with Sum — Medium
- Most Common Value — Medium
- Two Sum Exists — Medium
- Most Frequent Element — Medium
- Subarrays Summing to K — Hard
- Two Sum — Easy