24. 两两交换链表中的节点

递归交换每对相邻节点。

难度:中等。题型:Recursion。

标签:链表、递归

递归交换:head.next = swapPairs(next.next)。 时间复杂度 O(n),空间复杂度 O(n)。