Function to reverse a linked list

 struct Node* reverseList(struct Node *head)
    {               
        Node* nextnode = head;
        Node* current = head;
        Node* previous =NULL;
        
        while(nextnode!= NULL){
            nextnode = nextnode->next;
            current->next = previous;
            previous = current;
            current = nextnode;
        }
        
        head = previous;
        return head;
    }
Posted on by