leetcode - Swap Nodes in Pairs
来源:互联网 发布:大数据治理 pdf 编辑:程序博客网 时间:2024/06/03 20:28
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4
, you should return the list as 2->1->4->3
.
分析:指针操作
class Solution {public: ListNode *swapPairs(ListNode *head) { ListNode *CurNode = head; while(CurNode != NULL) { if(!CurNode->next)break; int temp = CurNode->next->val; CurNode->next->val = CurNode->val; CurNode->val = temp; CurNode = CurNode->next->next; } return head; }};
0 0
- LeetCode:Swap Nodes in Pairs
- LeetCode: Swap Nodes in Pairs
- [Leetcode] Swap Nodes in Pairs
- LeetCode : Swap Nodes in Pairs
- [LeetCode] Swap Nodes in Pairs
- Leetcode: Swap nodes in pairs
- [LeetCode]Swap Nodes in Pairs
- [LeetCode]Swap Nodes in Pairs
- LeetCode-Swap Nodes in Pairs
- LeetCode - Swap Nodes in Pairs
- LeetCode | Swap Nodes in Pairs
- 【leetcode】Swap Nodes in Pairs
- Leetcode: Swap Nodes in Pairs
- LeetCode - Swap Nodes in Pairs
- 【LeetCode】Swap Nodes in Pairs
- Leetcode: Swap Nodes in Pairs
- Leetcode Swap Nodes in Pairs
- LeetCode Swap Nodes in Pairs
- MD5加密
- UML中如何描述系统的体系结构(一)
- MagicalRecord使用方法
- 【OpenCV】Lab颜色空间
- UML中如何描述系统的体系结构(二)
- leetcode - Swap Nodes in Pairs
- Red Hat JBoss Fuse - RHTE Fuse and Camel 研討會習作
- UML中如何描述系统的体系结构(三)
- 软件开发生命周期(一)
- 软件开发生命周期(二)
- oracle语法备忘之循环
- android apk反编译
- 软件开发生命周期(三)
- Graphics.PageScale Graphics.ScaleTransform 的区别