DAY 15 LINKED LIST HACKKERANK
public static Node insert(Node head,int data) {
Node newNode=new Node(data);
Node temp=head;
if(head==null){
head=newNode;
return head;
}
else{
while(temp.next!=null){
temp=temp.next;
}
temp.next=newNode;
return head;
}
//Complete this method
}
Comments
Post a Comment