This challenge is part of a tutorial track by MyCodeSchool and is accompanied by a video lesson.
Given the pointer to the head node of a linked list, change the next pointers of the nodes so that their order is reversed. The head pointer given may be null meaning that the initial list is empty.
references the list
Manipulate the pointers of each node in place and return , now referencing the head of the list .
Complete the reverse function in the editor below.
reverse has the following parameter:
The first line contains an integer , the number of test cases.
Each test case has the following format:
The first line contains an integer , the number of elements in the linked list.
Each of the next lines contains an integer, the values of the elements in the linked list.
5 4 3 2 1
The initial linked list is: .
The reversed linked list is: .