My issue
find the error in code
My code
typedef struct LinkedList {
Node* head;
// 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
tail->next=newNode;
// Set new Node as the new tail
newNode=tail;
}
Learning course: Data structures and Algorithms
Problem Link: https://www.codechef.com/learn/course/pvp-dsa/PVPDAA01/problems/LINK01P04