2006. Count Number of Pairs With Absolute Difference K
https://leetcode.com/problems/count-number-of-pairs-with-absolute-difference-k
Description
Given an integer array nums
and an integer k
, return the number of pairs (i, j)
where i < j
such that |nums[i] - nums[j]| == k
.
The value of |x|
is defined as:
x
ifx >= 0
.-x
ifx < 0
.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= nums.length <= 200
1 <= nums[i] <= 100
1 <= k <= 99
ac
Previous2005. Subtree Removal Game with Fibonacci TreeNext2007. Find Original Array From Doubled Array
Last updated