zoukankan      html  css  js  c++  java
  • *Reverse Linked List

    题目:

    Reverse a singly linked list.

    代码:看不懂,我已经没救了

     1     public ListNode reverseList(ListNode head) {
     2         if (head == null) return head;
     3         ListNode cur = head;
     4         ListNode pre = null;
     5         while (cur.next != null){
     6             ListNode nextNode = cur.next;
     7             cur.next = pre;
     8             pre = cur;
     9             cur = nextNode;
    10         }
    11         cur.next = pre;
    12         return cur;
    13     }

    reference:http://blog.welkinlan.com/2015/05/06/reverse-linked-list-leetcode-java/

  • 相关阅读:
    【POJ
    【POJ
    【POJ
    【POJ
    【POJ
    【POJ
    【POJ
    【POJ
    NAT
    OSPF与ACL综合实验
  • 原文地址:https://www.cnblogs.com/hygeia/p/4717784.html
Copyright © 2011-2022 走看看