reverse a linked list in place.
Anonymous
I didn't start with the code immediately, I began by discussing how I will solve that, like I opted to use a stack to store the pointers then later traverse through to set the connection. My interviewer wanted something less memory consuming, I tried a number of other approaches which were good but not good enough then he gave me a hint to think about using two pointers. And it occurred to me that yes. I could use two pointers, one which holds the next node and the other the previous node. And use this to reverse the list in one for loop. After explaining this to him and he approved it, I then wrote the code just how I had explained it.
Check out your Company Bowl for anonymous work chats.