Home [Data Sturcture] LinkedList (vs ArrayList)
Post
Cancel

[Data Sturcture] LinkedList (vs ArrayList)

LinkedList Method List

  • Often using [*First] methods
    • addFirst
    • peekFirst
    • pollFirst
    • removeFirst

Screen Shot 2023-01-09 at 5 29 11 PM

Screen Shot 2023-01-09 at 5 31 29 PM

1
2
3
4
5
6
7
8
9
10
// if you want to make the reverse order list, use addFirst()

LinkedList<Integer> list = new LinkedList<>();
list.addFirst(1);
list.addFirst(2);
list.addFirst(3);

// list -> [3, 2, 1]

ArrayList VS LinkedList

  • Manipulation with LinkedList is faster than ArrayList

Screen Shot 2023-01-09 at 5 35 15 PM

This post is licensed under CC BY 4.0 by the author.

[Easy] Panlindrome Linked List

[Easy] Linked List Cycle

Comments powered by Disqus.