Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I agree with @cbalci and @igandecki. A single loop that iterates the array once is faster than looping the array multiple times.
Comparing 'for loop' to 'indexOf' is not the correct analysis here. The above solution goes throught the remaining list every time it removes an item. @Igandecki's point is fair. A single pass solution can be more efficent than this one.
Very interesting, I have no idea how this could possibly be true.. I will have to investigate. :)
Thanks!
@Igandecki
Time complexity is bounded by indexOf and splice which is the fastest way since we dont have to iterate through the array completely. Strangly even doing indexOf multiple times is faster than interating through the array completely. So it's the best way to do it.
source: http://jsperf.com/js-for-loop-vs-array-indexof/8
How is this voted up for the best practice?
It's nice to read and very short, let's even say "clever", but, it makes you go through the array multiple times - every time you run indexOf().
Very inefficient.