-
-
Save daviddamilola/5e99da275d34291648c32e204c2a95ce to your computer and use it in GitHub Desktop.
| export const getUniqueItemsFromArray = (array=[]) => { | |
| return Array.from(new Set(array)).length() | |
| } |
thanks @ndianabasi
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
Awesome solution. ๐๐