325 add two nunber


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;

        

    }

}

 
posted @ 2022-07-12 01:45  flag!  阅读(20)  评论(0)    收藏  举报