Hacker News new | ask | show | jobs
by arethuza 2703 days ago
Well, that's easy to fix - copy your array into a linked list so you an insert elements at the head efficiently. ;-)
1 comments

Yes, the real problem with this implementation is the data structure they use. But is `next == null` a special case? ogod what do we do?!
This is interesting. Is it possible to implement a linked list while eliminating the end of the list ‘edge case’, in the fashion of the parent article?
Create a "sentinel" node which represents null and also points to itself, perhaps?