Leetcode List: https://leetcode.com/list/9rizphpj

Like arrays, linked lists are used to represent sequential data. The benefit of linked lists is that insertion and deletion from anywhere in the list is O(1) whereas in arrays the following elements will have to be shifted.

Adding a dummy node at the head and/or tail might help to handle many edge cases where operations have to be performed at the head or the tail. The presence of dummy nodes essentially ensures that operations will never have been done on the head or the tail, thereby removing a lot of headache in writing conditional checks to deal with null pointers. Be sure to remember to remove them at the end of the operation.

Sometimes linked lists problems can be solved without additional storage. Try to borrow ideas from reverse a linked list problem.

For deletion in linked lists, you can either modify the node values or change the node pointers. You might need to keep a reference to the previous element.

For partitioning linked lists, create two separate linked lists and join them back together.

Linked lists problems share similarities with array problems, think about how you would do it for an array and try to apply it to a linked list.

Two pointer approaches are also common for linked lists. For example:

Be familiar with the following routines because many linked list questions make use of one or more of these routines in the solution: