#include using namespace std; struct Node { int data; Node* next; }; // Function to create a new node for a linked list Node* create_node(int value) { Node* newNode = new Node; newNode->data = value; newNode->next = nullptr; return newNode; } // Function to reverse a linked list Node* reverse_list(Node* head) { Node* prev = nullptr; Node* current = head; Node* nextNode = nullptr; while (current != nullptr) { nextNode = current->next; // Store the next node current->next = prev; // Reverse the link // Move pointers to the next positions prev = current; current = nextNode; } return prev; // The new head of the reversed list }