JavaScript Solution O(n) Beats 92%R and 100%M using map, easy to understand
\t/*\n\t * @param {number[]} nums\n\t * @param {number} k\n\t * @return {number}\n\t /\n\tvar findPairs = function(nums, k) {\n\t\tif(nums.length === 0 || k < 0
\t/**\n\t * @param {number[]} nums\n\t * @param {number} k\n\t * @return {number}\n\t */\n\tvar findPairs = function(nums, k) {\n\t\tif(nums.length === 0 || k < 0) return 0\n\t\tlet myMap = new Map(),\n\t\t\tcount = 0\n\t\t//Get wordcount\n\t\tfor(num of nums){\n\t\t\tmyMap.set(num,(myMap.get(num)+1) || 1)\n\t\t}\n\t\t\n\t\t//search solutions\n\t\tmyMap.forEach((value,key) =>{\n\t\t\tif(k === 0){\n\t\t\t\tif(value > 1) count++\n\t\t\t}\n\t\t\telse{\n\t\t\t\tif(myMap.has(key+k)) count++\n\t\t\t}\n\t\t})\n\n\t\treturn count\n\t};
['JavaScript']