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
|
1518 Discussions
|
Please Login in order to post a comment
same thing i am facing too
Subject: Issue with the "Insert a Node at a Specific Position in a Linked List" Challenge
Hello,
I am experiencing a problem with the "Insert a Node at a Specific Position in a Linked List" challenge. Specifically, I am encountering compilation errors related to the method declaration and access.
Errors Encountered:
*Illegal Static Declaration: The insertNodeAtPosition method, which is supposed to be used in the Result class, cannot be called directly due to the static modifier issue. This results in an error:
Solution.java:78: error: Illegal static declaration in inner class Solution.Result public static SinglyLinkedListNode insertNodeAtPosition(SinglyLinkedListNode llist, int data, int position) { Cannot Find Symbol: When attempting to call insertNodeAtPosition from the main method, the compiler reports that it cannot find the method:
Solution.java:128: error: cannot find symbol SinglyLinkedListNode llisthead = insertNodeAtPosition(llist.head, data, position);
here is my code(i've only written in the part inside the function insertNodeAtPosition, not changed anything in the set up)
: import java.io.; import java.math.; import java.security.; import java.text.; import java.util.; import java.util.concurrent.; import java.util.regex.*;
public class Solution {
}
**Request: **Could you please review the challenge setup and method declarations to ensure they align with the instructions provided? It appears that the method needs to be properly scoped and referenced to work within the provided code structure.
Thank you for your assistance.
Is there a way to do this in rust without having to use unsafe code blocks?
Sol in C++
In c language
SinglyLinkedListNode* insertNodeAtPosition(SinglyLinkedListNode* llist, int data, int position) { struct Node *ptr = (struct Node *)malloc(sizeof(struct Node )); struct Node * p = llist; int i = 0;
}