leetcode 24. Swap Nodes in Pairs

来源:互联网 发布:php项目经验描述 编辑:程序博客网 时间:2024/06/08 04:25
class Solution {public:ListNode* swapPairs(ListNode* head) {if ( head==NULL ||head->next == NULL ){return head;}ListNode *res = head->next;ListNode *temp = head->next->next;head->next->next = head;head->next = swapPairs(temp);return res;}};

0 0
原创粉丝点击