в общем, прошу посощи. Зарегестрировался на hackerrank.com выбрал тему и стал выполнять задания, первое выполнил, а вот во втором что-то понять не могу, где я ошибаюсь, подскажите пожалуйста
Input Format You have to complete the Node* Insert(Node* head, int data) method which takes two arguments - the head of the linked list and the integer to insert. You should NOT read any input from stdin/console.
Output Format Insert the new node at the tail and just return the head of the updated linked list. Do NOT print anything to stdout/console.
Sample Input
NULL, data = 2 2 --> NULL, data = 3
Sample Output
2 -->NULL 2 --> 3 --> NULL
Explanation 1. We have an empty list and we insert 2. 2. We have 2 in the tail, when 3 is inserted 3 becomes the tail.
вот мое решение
/*
  Insert Node at the end of a linked list 
  head pointer input could be NULL as well for empty list
  Node is defined as 
  struct Node
  {
     int data;
     struct Node *next;
  }
*/
Node* Insert(Node *head,int data)
{
    Node *tmp = (Node *)malloc(sizeof(Node));
    tmp->data = data; tmp->next = NULL;
    if (head == NULL) {
        head = tmp;
        return tmp;
    }
    for (; head->next != NULL; head = head->next);
    head->next = tmp;
    return head;
}





