力扣-24. 两两交换链表中的节点
题目:给你一个链表,两两交换其中相邻的节点,并返回交换后链表的头节点。你必须在不修改节点内部的值的情况下完成本题(即,只能进行节点交换)。

=
public static ListNode swapPairs(ListNode head) {
if(head==null||head.next==null)
return head;
//
ListNode one=head;
ListNode two=one.next;
one.next=two.next;
two.next=one;
ListNode current=two.next.next;
ListNode twotemp=null;
ListNode prev_cur=two.next;
while(current!=null&¤t.next!=null){
twotemp=current.next;
current.next=twotemp.next;
twotemp.next=current;
prev_cur.next=twotemp;
current=twotemp.next.next;
prev_cur=twotemp.next;
}
return two;
}
=

*
备注:公众号清汤袭人能找到我,那是随笔的地方
备注:公众号清汤袭人能找到我,那是随笔的地方