Partially Revert Linked List
Problem: partially revert a linked list
Given a HEAD pointer to a linked list and an OFFSET pointer pointing to a node in the linked list. You are asked to write a C/C++ subroutine to revert the part of the list from HEAD to OFFSET:
You are NOT allowed to use recursion. Please follow the definition of the type and function as shown below:
typedef struct _Node
...{
int value;
struct _Node* next;
}Node;
Node* Revert(Node* head, Node* offset)
...{
//Your code here. Return the head of new linked list.
}
Exchange Nodes
Problem: Exchange the odd and even nodes in a linked list.
Given a "head" pointer to a linked list. You are asked to write a C/C++ function to exchange the odd and even nodes in the linked list. For example:
Please follow the type and function definitions below:
typedef struct _Node
...{
int value;
struct _Node* next;
}Node;
void ExchangeNodes(Node** phead) //note: phead is of Node** type
...{
//your code here.
}