题解 | #反转链表#
反转链表
http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
思路:pre cur nex
前提是链表非空 while(cur) nex = cur->next = cur=nex; pre 是cur->next= cur的辅助指针 nex = cur ->next cur->next = pre; pre = cur; cur = nex
反转链表
http://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
思路:pre cur nex
前提是链表非空 while(cur) nex = cur->next = cur=nex; pre 是cur->next= cur的辅助指针 nex = cur ->next cur->next = pre; pre = cur; cur = nex
相关推荐