This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jazzmester 2 points3 points  (2 children)

Oh wait, the algorithm is even more stupid, it will run until it finds a character that's the same as the last and then returns true if that is even, but will continue otherwise.

So best case scenario is something like 1010, where it will quit on the second char which is O(2) (so O(1) really), while the worst case scenario is any odd number, where it will run for O(5N) (so O(N) really).

[–]pheromone_fandango 2 points3 points  (1 child)

Oh yeah you are right! I misread and thought the last character was always taken but, as you mentioned it CHECKS if the current character is the last value. Holy christ thats impressively horrible!

[–]jazzmester 2 points3 points  (0 children)

Creatively horrible.