题意:
交换相邻(adjacent)的节点
我的思路;
//c++ recursive,效率是不高但是比较短
class Solution {
public:
ListNode* swapPairs(ListNode* head) {
if(!head || !(head->next)) return head;
ListNode *c = head, *n = head->next, *f = head->next->next;
n->next = c;
c->next = swapPairs(f);
return n;
}
};