diff --git a/Hacker rank Problem Solving/Insert a Node at the Tail of a Linked List b/Hacker rank Problem Solving/Insert a Node at the Tail of a Linked List new file mode 100644 index 0000000..3aa902d --- /dev/null +++ b/Hacker rank Problem Solving/Insert a Node at the Tail of a Linked List @@ -0,0 +1,19 @@ +Node* Insert(Node *head,int data) +{ + Node* temp = new Node(); + temp->data = data ; + temp->next = NULL ; + Node* root = head ; + if(head == NULL){ + head = temp; + head->next = NULL; + return head; + } + else{ + while(head->next != NULL){ + head = head->next; + } + head->next = temp; + return root; + } +}