其他分享
首页 > 其他分享> > 328 Odd Eeven Linked list

328 Odd Eeven Linked list

作者:互联网

 

 

 

 

class Solution {

    public ListNode oddEvenList(ListNode head) {

        if(head==null) return null;

        ListNode odd=head,even=head.next,evenHead=even;

        while(even!=null&&even.next!=null){

            odd.next=even.next;

            odd=odd.next;

            even.next=odd.next;

            even=even.next;

        }

        odd.next=evenHead;

        return head;

        

    }

}

 

标签:even,head,ListNode,odd,Eeven,next,328,null,Odd
来源: https://www.cnblogs.com/LLflag1/p/16468573.html