struct node * reverseSingleLink(struct node * head) {
if(head == NULL)
return head;
if(head->next == NULL)
return head;
struct node * post = head;
struct node * cur = head->next;
struct node * pre = cur->next;
while(pre != NULL) {
cur->next = post;
post = cur;
cur = pre;
pre = cur->next;
}
cur->next = post;
head->next = NULL;
return cur;
}
时间复杂度: O(n)