We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Insert a node at a specific position in a linked list
Insert a node at a specific position in a linked list
Sort by
recency
|
1537 Discussions
|
Please Login in order to post a comment
Here is my C++ solution, you can watch the explanation here : https://youtu.be/jCPAp_UIzAs
Problem has a confusing description. In the problem description tells you to return the list head node but the comments in the code tell you to return the whole list which can be confusing. INTEGER_SINGLY_LINKED_LIST should be INTEGER_SINGLY_LINKED_LIST_NODE (LIST HEAD)
public static SinglyLinkedListNode insertNodeAtPosition(SinglyLinkedListNode head, int data, int position) {
}
Before this you will need to remove the Result class and it's braces in order for code to compile.
The starting boiler plate in Java needs to be refactored or else it will never compile.