leet24
2016-12-18 20:56
225 查看
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(head==NULL)
return head;
if(head->next==NULL)
return head;
ListNode *temp=head->next;
head->next=swapPairs(temp->next);
temp->next=head;
return temp;
}
};
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(head==NULL)
return head;
if(head->next==NULL)
return head;
ListNode *temp=head->next;
head->next=swapPairs(temp->next);
temp->next=head;
return temp;
}
};
相关文章推荐
- 小白学《神经网络与深度学习》笔记之二-利用稀疏编码器找图像的基本单位(1)MatLab实现SparseAutoEncoder
- Jar包下载
- 使用java mail 发送邮件
- 缓存一致性
- javaSE 基础总结
- 线性回归 numpy normal equation & tensorflow gradient descent
- AndroidStudio如何添加悬浮提示
- 菜鸟学Linux 第052篇笔记 httpd-install and section2
- LeetCode 167. Two Sum II - Input array is sorted
- 一起talk C栗子吧(第一百九十三回:C语言实例--DIY less命令二 )
- 最优化复习要点
- JMeter常用测试元件—学习笔记
- 网络编程中的粘包处理
- java 如何实现等待子线程结束
- jQuery中对同一个元素使用mouseover和mouseout产生闪烁问题
- ECMAScript6(ES6)标准之解构赋值语法及应用
- MS Com注册表信息及其注册过程
- java 实现短信验证码功能
- C#点滴积累
- webpack1.x + ElementUI 初探