leetcode 206: Reverse Linked List
2015-08-09 15:26
337 查看
/** * 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 head; ListNode* res=head; helper(head,res); return res; } ListNode* helper(ListNode* head,ListNode*& phead) { if(head->next==NULL) { phead=head; return head; } ListNode* p=helper(head->next,phead); p->next=head; head->next=NULL; return head; } };
相关文章推荐
- 关于创新工场的一道笔试题
- Frame Stacking(拓扑排序)
- 上传控件动态化(具体的自己控制吧,像id classs属性)3
- Your build settings specify a provisioning profile with the UUID “XXXX”
- 第79讲:单例深入讲解及单例背后的链式表达式
- Android-PullToRefresh下拉刷新,上拉加载的使用详解
- 字符串的全排列(java)
- 1028. 人口普查(20)
- POJ3660 Cow Contest(floyd)
- C#匿名类型(Anonymous Type)学习日记
- Android基于GridView实现的翻牌游戏效果
- Redis之Java增删改查
- 【集合中的内存管理,常用结构体,基本数据类型和包装数据类型的转换 NSDate】
- ruby命令行的输入数据
- Linux之find命令用于统计信息
- POJ 1276 Cash Machine
- 查找数组中第二个最小元素
- 移动终端前端开发概述
- IIS Express 添加MIME映射
- Error:const char* 类型的实参和LPCWSTR类型的形参不兼容的解决方法。