Reverse Even Nodes in a Linked List
Given a singly linked list, reverse the nodes at even positions.
We'll cover the following...
Statement
Given a singly linked list, reverse the nodes at even positions and return the linked list.
Example
Let’s take the below linked list as an example:
After reversing the nodes at even positions, it should look like this:
Sample input
[7, 14, 21, 28, 9]
Expected output
[7, 28, 21, 14, 9]
Try it yourself
main.cpp
LinkedList.cpp
LinkedListNode.cpp
#include <vector>#include "LinkedList.cpp"using namespace std;typedef LinkedListNode* NodePtr;NodePtr ReverseEvenNodes(NodePtr head) {//TODO: Write - Your - Codereturn head;}
...