Reverse List

Consider the following struct for a doubly linked list.

        struct list_node
        {
            int m_value;
            list_node* m_previous = nullptr;
            list_node* m_next = nullptr;
        };

Implement the function

        list_node* reverse(list_node* head);

that reverses in-place the given list, without dynamic memory
allocations, and returns a pointer to its new head.

Observation

You only need to submit the required classes; your main program will be
ignored.

Strictly obey the type definitions of the statement.

Problem information

Author: Xanadu Trading

Generation: 2026-01-25T15:19:32.439Z

© Jutge.org, 2006–2026.
https://jutge.org
