leetcode 24 Swap Nodes in Pairs C++
来源:互联网 发布:bjd娃娃6分娃淘宝 编辑:程序博客网 时间:2024/06/03 06:06
注意只能换节点,不能换值。
class Solution {public: ListNode* swapPairs(ListNode* head) { ListNode *cur = head; ListNode *preCur = NULL; if(head&&head->next) head = head->next; while(cur){ if(cur->next){ ListNode *tmp = cur->next->next; cur->next->next = cur; if(preCur) preCur->next = cur->next; preCur = cur; cur->next = tmp; } cur = cur->next; } return head; }};
0 0
- 【LeetCode-24】Swap Nodes in Pairs(C++)
- LeetCode 24 Swap Nodes in Pairs (C,C++,Java,Python)
- leetcode: Swap Nodes in Pairs (C++)
- 【C++】【LeetCode】24. Swap Nodes in Pairs
- Leetcode c语言-Swap Nodes in Pairs
- [C语言][LeetCode][24]Swap Nodes in Pairs
- LeetCode(24)Swap Nodes in Pairs
- [LeetCode 24] Swap Nodes in Pairs
- [leetcode 24]Swap Nodes in Pairs
- LeetCode | #24 Swap Nodes in Pairs
- [Leetcode 24 链表]Swap Nodes in Pairs
- leetcode 24 Swap Nodes in Pairs
- 【leetcode】【单链表】【24】Swap Nodes in Pairs
- Leetcode 24 Swap Nodes in Pairs
- Swap Nodes in Pairs - LeetCode 24
- LeetCode 24 - Swap Nodes in Pairs
- leetcode 24 -- Swap Nodes in Pairs
- LeetCode 24:Swap Nodes in Pairs
- linux select()详解(一)-- 使用及注意事项
- kSumII
- cookie和session的区别
- 傅里叶变换分析
- 读书笔记-叁-《结网》
- leetcode 24 Swap Nodes in Pairs C++
- 顺序表应用5:有序顺序表归并
- 【转载】springMVC表单校验+全注解
- 深入理解Java:SimpleDateFormat安全的时间格式化(多线程应用)
- Java 反射
- viewpager+fragment 懒加载操作
- poj 2387
- 安卓传感器入门(1)
- 获取颜色值