📅  最后修改于: 2022-03-11 15:03:26.209000             🧑  作者: Mango
// picking numbers hackerrank solution javascript
function pickingNumbers(a) {
// Write your code here
let sorted = a.sort(function(a, b) {
return a - b;
});
let i = 0;
let j = 1;
while(i < sorted.length && j < sorted.length) {
if(Math.abs(sorted[i] - sorted[j]) > 1) {
i++;
j++;
} else {
j++;
}
}
return Math.abs(i - j);
}