fn reverse_k(mut head: Option<Box<ListNode>>, k: i32) -> Option<Box<ListNode>> {
        let mut len = 0;
        let mut cur = &mut head;
        while let Some(_cur) = cur {
            cur = &mut _cur.next;
            len += 1;
            if len >= k {
                break;
            }
        }
        if len < k {
            return head;
        }
        let mut tail = Self::reverse_k(cur.take(), k);
        let mut head = Self::reverse(head);
        let mut cur = &mut head;
        loop {
            if let Some(ref mut _cur) = cur {
                cur = &mut _cur.next;
            } else {
                break;
            }
        };
        *cur = tail.take();
        head
    }
/// reverse k-nodes and return the tail nodes.
reverse k-nodes and return the tail nodes.
reverse k - nodes and return the tail nodes .
fn reverse_k(mut head: Option<Box<ListNode>>, k: i32) -> Option<Box<ListNode>> {
        let mut len = 0;
        let mut cur = &mut head;
        while let Some(_cur) = cur {
            cur = &mut _cur.next;
            len += 1;
            if len >= k {
                break;
            }
        }
        if len < k {
            return head;
        }
        let mut tail = Self::reverse_k(cur.take(), k);
        let mut head = Self::reverse(head);
        let mut cur = &mut head;
        loop {
            if let Some(ref mut _cur) = cur {
                cur = &mut _cur.next;
            } else {
                break;
            }
        };
        *cur = tail.take();
        head
    }
fn reverse_k ( mut head : Option < Box < ListNode > > , k : i32 ) -> Option < Box < ListNode > > { let mut len = 0 ; let mut cur = & mut head ; while let Some ( _cur ) = cur { cur = & mut _cur . next ; len += 1 ; if len >= k { break ; } } if len < k { return head ; } let mut tail = Self :: reverse_k ( cur . take ( ) , k ) ; let mut head = Self :: reverse ( head ) ; let mut cur = & mut head ; loop { if let Some ( ref mut _cur ) = cur { cur = & mut _cur . next ; } else { break ; } } ; * cur = tail . take ( ) ; head }
reverse k-nodes and return the tail nodes.
reverse k - nodes and return the tail nodes .
head
Option<Box<ListNode>>
k
i32