Solution to Print List from End from Jobdu

31 Jul

Question (in Chinese):

Question Name: Print List from End

Question Description: giving a single-linked list, print the values of its nodes from end to beginning.

Input: multiple lines. Each line is an integer. -1 means reaching the end of list. And -1 is not a part of the list.

Output: the values in reversed order.

The solution is easy with stack.

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!