Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • It is not actually. It is more my stupid mistake for saying that in the end of my comment ;P. As you can see the first reply to my comment explains that I am wrong in a funny way :D.

    Again sorry for the last part of my comment and thanks for the reply.

  • How is this O(n/2) if you're still doing ~n comparisons? The loop runs n/2 times but you do 2 comparisons per loop. O(n) is still great though, better than sorting

  • tecnically speaking it was O(n / 2)

    You could improve it drastically by splitting the array into n 1-element-long segments, and have O(n / n) = O(1) time complexity :+1:

  • This is an ok solution. But that's all.
    It is the same as all standard solutions, just more nice to the eye.

    The kata specifies to give emphasis to efficiency!

    Go check my solution, I solved it in O(N). Even though tecnically speaking it was O(N/2), so half the time!!!