Ad
  • Custom User Avatar

    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

  • Custom User Avatar

    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.

  • Custom User Avatar

    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

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    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

  • Custom User Avatar

    wdym consultant?

    also sorry for the dead code and putting the main function at the very end

  • Custom User Avatar

    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.