有序环链表按顺序插入元素

有序升序环链表,找到最小头

        Node newhead = null;
        Node slow = head;
        Node fast = head.next;
        while(fast.val >= slow.val){
            slow = slow.next;
            fast = fast.next;
            if(fast == head){
                break;
            }
        }    

然后从新头找到元素位置插入即可

posted @ 2021-08-26 15:10  K峰  Views(85)  Comments(0)    收藏  举报