import java.util.*;
public class Solution {
public ListNode swapLinkedPair (ListNode head) {
// write code here
//通过递归来做与反转链表类似,先逆置前两个,
//子问题函数:将第三个后面的全部两两逆置,传入头节点
//截至函数:
if(head==null||head.next==null){
return head;
}
ListNode nNode = swapLinkedPair(head.next.next);
ListNode ret = head.next;
//改变指针指向
ret.next = head;
head.next = nNode;
return ret;
}
}



京公网安备 11010502036488号