Revers a list
//reverse a list
//this question are frequently asked in interview. hope it can help you.
static void Reverse(struct node** node){ // don't tell me you can't understand the **
//1. declare three pointer
struct node* result = NULL;
struct node* current = *headRef;
struct node* next;
while (current != NULL) {
next = current->next; // tricky: note the next node
current->next = result; // move the node onto the result
result = current;
current = next;
}
*headRef = result;
}
//this question are frequently asked in interview. hope it can help you.
static void Reverse(struct node** node){ // don't tell me you can't understand the **
//1. declare three pointer
struct node* result = NULL;
struct node* current = *headRef;
struct node* next;
while (current != NULL) {
next = current->next; // tricky: note the next node
current->next = result; // move the node onto the result
result = current;
current = next;
}
*headRef = result;
}