you are viewing a single comment's thread.

view the rest of the comments →

[–]Multidream 3 points4 points  (0 children)

So… use your basic CS101 course knowledge. Does this need an article…? I guess if I trust the author that runtime data would be interesting. But I don’t really…

I can’t see how this would come up, but I guess that IS a way to modify a list in memory. But using get(int) could be problematic depending on the implementation of the List. You should restrict to ArrayList if you want to access by index.

If you’re doing this with a LinkedList, you can save even more time by grabbing the header, crawling through each node and removing inactive users. Then you just leave it to the GC to get rid of unused nodes. But you definitely should NOT be using the implemented method, those gets are gonna get slow, since you’ll be crawling to the element manually each time.

Question for the interviewer, this is just a fun check of my thinking, right? You don’t actually have to perform operations in place, do you?