Last active
April 12, 2021 09:01
-
-
Save daviddamilola/5e99da275d34291648c32e204c2a95ce to your computer and use it in GitHub Desktop.
remove duplicates
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
export const getUniqueItemsFromArray = (array=[]) => { | |
return Array.from(new Set(array)).length() | |
} |
Woah, very efficient. Good!
If you can solve a problem in fewer lines of code, do it and you definitely did that @daviddamilola. Thanks for participating in Week 1 of Algorithm Fridays.
I really like that your solution takes care of possible null
values for input by setting a default value of the array to be an empty array.
The only question I have is, is there a way we could have solved this problem without using another data structure?
I have posted my solution here, let me know what you think.
many thanks for taking the time to give feedback @meekg33k , the counting solution is an eye opener for me and thinking of pros and cons to any approach too.... looking forward to next Friday🎉
Woah, very efficient. Good!
thanks @mejtfk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks @ndianabasi