Created
June 16, 2018 17:15
-
-
Save indefinitelee/93700fdf7c68943ddc619d248e9318e3 to your computer and use it in GitHub Desktop.
MajorLikableCases created by indefinitelee1 - https://repl.it/@indefinitelee1/MajorLikableCases
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 uniqSort = function(arr) { | |
const memo = {[arr[0]] : true}; | |
const result = [arr[0]]; | |
for (let i = 1; i < arr.length; i++) { | |
if (!memo[arr[i]]) { | |
result.push(arr[i]); | |
memo[arr[i]] = true; | |
} | |
} | |
return result.sort((a,b) => a - b); | |
} | |
uniqSort([4,2,2,3,3,3,3,2,2,4]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment