91. Reverse Linked List 反转链表

网址:https://leetcode.com/problems/reverse-linked-list/

直接参考92:https://www.cnblogs.com/tornado549/p/10639756.html

/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* reverseList(ListNode* head)
{
if(!head)
return NULL;
ListNode* a = NULL;
ListNode* b = head;
ListNode* c = b->next;
while(c)
{
b->next = a;
a = b;
b = c;
c = c->next;
}
b->next = a;
return b;
}
};

91. Reverse Linked List 反转链表

上一篇:VS Code 常用插件


下一篇:Eclipse:新的Android测试项目无法打开android测试向导