Created
February 12, 2018 05:34
-
-
Save thebopshoobop/093e8e4daea500a06378473bd4b42272 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const simplify = sample => { | |
let deDup = []; | |
for (let current of sample) { | |
deDup[current] = true; | |
} | |
return Object.keys(deDup) | |
.map(i => +i) | |
.sort((a, b) => a - b); | |
}; |
const simplify = sample => {
let deDup = {};
for (let current of sample) {
deDup[current] = current;
}
return Object.values(deDup).sort((a, b) => a - b);
};
Now with even more counting sort. This one is even faster, somehow.
const simplify = sample => {
let deDup = [];
for (let current of sample) {
deDup[current] = true;
}
let result = [];
for (let current in deDup) {
result.push(+current);
}
return result;
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also is
const
faster thanfunction
??