swap nodes in pairs
来源:互联网 发布:如何把矩阵正交化 编辑:程序博客网 时间:2024/06/07 22:01
/**
* 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 NULL;
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 NULL;
if(head->next == NULL) return head;
ListNode* temp = head->next;
head->next = swapPairs(temp->next);
temp->next = head;
return temp;
}
};
阅读全文
0 0
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes In Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Swap Nodes in Pairs
- Python 正则表达式
- Android7.0中文文档(API)--- DialerFilter
- 【ROS书籍】ROSByExampleⅡ——第三章 使用ROS任务执行
- oracle导入.dmp文件过程遇到的问题解决
- springboot中发送各种类型的邮件
- swap nodes in pairs
- 【面试题22】二叉搜索树的后序遍历
- activity之间的切换效果
- Base64随记
- QT Creator4.3制作图标
- SYD8801 UART使用说明【uart轮发数据代码实现】【 uart中断发数据代码实现】【RFSleep函数对串口的影响】【中断中调用串口打印函数有可能会造成死机】
- 554. Brick Wall
- Thrift使用示例
- Vuforia和CardBoard冲突问题