Help me in solving LINK01P04 problem

My issue

Need answer

My code

typedef struct LinkedList {
    Node* head;
    Node* next;
    // Create the Node tail
    Node* tail;
    
} LinkedList;

// Function to insert a node at the end of the linked list
void insertAtEnd(LinkedList* list, int value) {
    Node* newNode = createNode(value);

    // If there are no nodes in the linked list
    // Set the new node as head and tail
    if (list->head == NULL) {
        list->head = newNode;
        list->tail = newNode;
        return;
    }

    // Set next of tail to the new Node
    Node* tail->next=newNode;
    // Set new Node as the new tail
    Node* tail=newNode;
}

Learning course: Data structures and Algorithms
Problem Link: Optimal insertion at the end in Data structures and Algorithms