Posts Tagged ‘linked list’
Picking the 5th from last element in a singly linked list
Here's another of those fun coding interview puzzles. The kind that companies like Microsoft or Google might ask you. Given a singly linked list, select the 5th from last element. I'm writing the solution in C++ but the solution in Java would be almost identical. I'm also putting up my test code. The restrictions are - you can only make one [...]
Reverse a linked list – C++ source code
Reversing a linked list is a simple programming problem, which is often an interview question. In this case I'm referring to a singly linked list. I'll provide the C++ solution and the C++ test code. One of the easiest ways to reverse the linked list is to create a new head pointer, iterate through the list removing each item in turn and then [...]









