Reverse Linked List 2020-09-11 08:45

Problem Description

public static ListNode reverseList(ListNode head) {
    ListNode pre = null;
    ListNode current = head;
    ListNode next;
    while (current != null) {
        next = current.next;
        current.next = pre;
        pre = current;
        current = next;
    }
    return pre;
}
Runtime Memory
0 ms 39.4 MB

henryxi leetcode list

EOF