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.
You should be correct, this is O(2n). This solution should be perfectly acceptable and scale just fine with large lists. There is no need to optimize unless the code is causing actual performance issues. Readability and intent should be king unless you are seeing some issues with the code. Even running this with 6x CPU throttling, the duration for filter-then-reduce is 0.6ms for me on an array with 10000 elements. (Base CPU Ryzen 5 3600X, throttled 6x using Chrome dev tools) Unless this is being run extremely frequently or on extraordinarily large lists, it should not be a noticeable problem.
I'm sorry for inflicting this on the world.