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 did not know that Java has functional patterns / iterators. Nice!
i am about half your age, so you may consider me a kid
all i wanna say is that it's not all about the big O; by saying that my solution is 10x faster i'm just giving an example of two O(n) implementations that are quite different
and if you don't get it, my first comment was a criticism of HotMugger's statements
Are you a kid? Are you trying to elicit a kid argument with "my solution is 10x faster. No, my solution is 100x faster. No, it's infinity faster. No, its infinity x infinity faster".
Grow up.
ChatGPT moment
not all O(n) are the same, coefficients vary. the term suboptimal applies well
my solution is about 10x faster than this one
This comment is hidden because it contains spoiler information about the solution
the pushes will just assign capacity to the next power of 2 when len is a power of 2. and there will be no moving of elements unless the next capacity is at least 2^16 or even higher
still, it would be best to use with_capacity and omit capacity checks
wdym consultant?
also sorry for the dead code and putting the main function at the very end
it wouldnt be complete without iterators :)
needs more iterators apparently
I found the consultant :)
risky :D
Although that is all true to my recollection...why bother doing a conversion into a vector an returning it? It wants you to return a vector so I gave it one. In hindsight I do wish I allocated the size at creation if that was what your getting at.
This is nice to read, but has sub-optimal performance. Every push will make a slightly bigger copy of 'vec' to keep up with size. So for n elements, the first push copies 1, then 2, then 3, ... , then n elements, resulting in O(n^2) runtime (Gauß). Dynamically sized data types are a lie.