将一个链如下反转:
输入链 : 1 -> 2 -> 3 -> 4
输出 : 2 -> 1 -> 4 -> 3
python
def swap(head): if (head == None) or (head.next== None): return head tmp = ListNode() tmp = head.next head.next = swap(tmp.next) tmp.next = head