LeetCode-Swap Nodes in Pairs
2014-04-20 21:23
507 查看
#include <iostream> using namespace std; struct ListNode { int val; ListNode *next; }; void Swap(int *a,int *b) { int temp=*a; *a=*b; *b=temp; } ListNode *swapPairs(ListNode *head) { if(head==NULL) return NULL; if(head->next==NULL) return head; ListNode *node=head; while(node->next!=NULL) { Swap(&node->val,&node->next->val); if(node->next->next!=NULL) node=node->next->next; else break; } return head; }
相关文章推荐
- LeetCode 24_Swap Nodes in Pairs
- [Leetcode]_24 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 24 - Swap Nodes in Pairs
- LeetCode 24. Swap Nodes in Pairs
- leetcode-24. Swap Nodes in Pairs
- [LeetCode]Swap Nodes in Pairs
- Swap Nodes in Pairs - LeetCode
- [LeetCode]Swap Nodes in Pairs
- LeetCode 24. Swap Nodes in Pairs
- LeetCode 24. Swap Nodes in Pairs
- LeetCode | Swap Nodes in Pairs
- LeetCode : Swap Nodes in Pairs [java]
- leetcode 24. Swap Nodes in Pairs \ 21. Merge Two Sorted Lists
- 【leetcode】Swap Nodes in Pairs