Hackerrank: Insert a node at a specific position in a linked list

preview_player
Показать описание
Insert a node at a specific position in a linked list hackerrank problem walkthrough.
Рекомендации по теме
Комментарии
Автор

Hey brother need help
i have written this code and its giving me error
"Solution.java:81: error: cannot find symbol
if(head==null){
^"

my code
SinglyLinkedListNode node = new SinglyLinkedListNode(data);

if(head==null){
node=head;
return head;
}
SinglyLinkedListNode current = head;
for (i=1;i<position;i++){
current = current.next;
}
node.next=current.next;
current.next=node;
return head;
can u see what is wrong??

mdshaadmanlodhi
welcome to shbcf.ru