交换链表相邻的两个结点
/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode swapPairs(ListNode head) {
if(head == null || head.next == null) return head;
ListNode list = head.next;
ListNode list1 = list.next;
list.next = head;
head.next = swapPairs(list1);
return list;
}
}