leetcode_c++:链表:Reverse Linked Lis(206)
2016-07-18 16:21
375 查看
Reverse Linked Lis
class Solution { public: ListNode* reverseList(ListNode* head) { if(head==NULL||head->next==NULL) return head; ListNode* dummy=new ListNode(-1); dummy->next=head; ListNode* prev=head,*cur=head->next; while(cur){ prev->next=cur->next; cur->next=dummy->next; dummy->next=cur; cur=prev->next; } return dummy->next; } };
相关文章推荐
- C语言合并排序及实例代码
- C/C++ 静态链接库(.a) 与 动态链接库(.so)
- leetcode_c++:链表:Remove Linked List Elements(203)
- leetcode_c++:链表:Intersection of Two Linked Lists(160)
- 浅谈C/C++中static extern关键字的作用
- Leetcode 58. Length of Last Word (Easy) (cpp)
- C++拷贝构造函数详解
- C++四种常用的类型转换机制
- MTCNN--《Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks》疑问一大堆
- c++之getopt函数的使用
- C语言_向函数传递结构体信息_plusC14.5
- 快速排序算法C语言
- 【链表】C++链表反转、链表逆序打印
- ROS学习之 cpp服务
- 【C语言入门教程】5.6 函数库和文件
- 【C语言入门教程】5.5 实现问题(效率)
- 【C语言入门教程】5.4 递归
- 【C语言入门教程】5.3 函数的调用 与 参数
- Leetcode 38. Count and Say (Easy) (cpp)
- 【C语言入门教程】5.2 函数的作用域规则(auto, static)