美文网首页
2018-11-07

2018-11-07

作者: khkhkjkljguguy | 来源:发表于2018-11-07 21:22 被阅读0次
    class Solution {
        public ListNode reverseList(ListNode head) {
            ListNode current = head;
            ListNode pre = null;
            
            ListNode newHead = null;
            while(current != null){
                ListNode next = current.next;
                if (next == null) {
                    newHead = current;
                }
                current.next = pre;
                pre = current;
                current = next;
            }
            return newHead;
        }
    }
    

    相关文章

      网友评论

          本文标题:2018-11-07

          本文链接:https://www.haomeiwen.com/subject/zpybxqtx.html