K-diff Pairs in an Array
Given an array of integers and an integerk, you need to find the number ofuniquek-diff pairs in the array. Here ak-diffpair is defined as an integer pair (i, j), whereiandjare both numbers in the array and theirabsolute differenceisk.
Example 1:
Example 2:
Example 3:
分析
就是2sum的思想,排序后,a和a-k pair存入map
Last updated