Solution to Reverse List from Jobdu

7 Aug

Question (in Chinese): http://ac.jobdu.com/problem.php?pid=1518

Question Name: Reverse List

Question Description: Give an single-linked list, reverse it in place.

Input: the input might contain multiple test cases. Inside each test case, the first line is one interger N (0 <= N <= 1000), saying the size of the list. The second line includes N integers, as the value of each node in the list.

Output: “NULL” if N is 0. Otherwise, reverse the list, and print out the value of each node in the reversed list from beginning to end.

Classic problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!