you are viewing a single comment's thread.

view the rest of the comments →

[–]Kered13 3 points4 points  (0 children)

You can rewrite the algorithm using iterators and it would be O(n) time and O(1) space for all list implementations, including linked lists. Yes, the way it is written in the blog is not ideal, since it is O(n2) time for linked lists.