Recently I had an interview and the interviewer asked me to reverse a singly linked list without modifying the pointers(change the values only). At the beginning I came up with a solution using a stack. He said that was OK and wanted me to do it recursively. Then I gave him a O(n^2) solution. But he said he needs a O(n) solution.
Anyone can help me?