您的位置:首页 > 其它

leet24

2016-12-18 20:56 225 查看
/**

 * 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 head;

        if(head->next==NULL)

            return head;

         ListNode *temp=head->next;

         head->next=swapPairs(temp->next);

         temp->next=head;

        return temp;

    }

};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: