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.
Yes, it is very slow, O(n²), and one should use a different solution for bigger lists, eg. using a set/hash table. However, there is no solution with O(log n). You need to look through all items in the list, so you will always have at least O(n). Solutions using sorting (eg. quicksort) or building hash tables will probably have O(n log n) at least.
this one is very big brain i like it
Unfortunately, it is too slow. What about real DB, for example, 100 000 items? I think here we need something with O(log(n)). Maybe something like this: https://www.codewars.com/kata/reviews/56024ec67903d24c8e00002d/groups/57860f9522542afb0b0001d1
This solution a bit faster then simple array looping. With 100 000 items:
simple loop: 75.1681 sec
this one: 0.025 sec