Print a singly-linked list backwards, in constant space and linear time
I heard an interview question: "Print a singly-linked list backwards, in constant space and linear time." My solution was to reverse the linkedlist in place and then print it like that. Is there another solution that is nondestructive? If you reverse it again after printing it will no longer be destructive, since the original order is restored. You've already figured out most of the answer: reverse the linked list in place, and traverse the list back to the beginning to print it. To keep it from being (permanently) destructive, reverse the linked list in place again as you're traversing it