- class Solution {
- public:
- ListNode* reverseList(ListNode* head) {
- if(head==NULL)
- return NULL;
- ListNode* pre = new ListNode(-1);
- pre->next = head;
- ListNode* cur = head;
- ListNode* nex = head;
- while(cur->next){
- nex = cur->next;
- cur->next = nex->next;
- nex->next = pre->next;
- pre->next = nex;
- }
- return pre->next;
- }
- };
链表逆序
猜你喜欢
转载自blog.csdn.net/jwy2014/article/details/79514678
今日推荐
周排行