K-diff Pairs in an Array
Medium · Hashing · about 15 minutes
Asked at Amazon, Google, Meta, Microsoft.
Return the number of unique pairs (a, b) of values from nums (at different indices) with |a - b| == k. Pairs are unordered: (1, 3) and (3, 1) are the same.