Created
June 29, 2022 02:58
-
-
Save RakhmedovRS/f18182ba692a76502f4444bf58410af6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add a node of value val before the first element of the linked list. After the insertion, the new node will be the first node of the linked list. | |
*/ | |
public void addAtHead(int val) | |
{ | |
Link link = new Link(val); | |
//--> | |
head.next.prev = link; | |
link.next = head.next; | |
//<-- | |
head.next = link; | |
link.prev = head; | |
size++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment