(0ms) Very Simple and Clear Iterative java solution


  • 0
    F

    Here is my iterative java solution:

    class Solution {
        public ListNode reverseList(ListNode head) {
            ListNode currNode = head, nextNode = null, prevNode = null;
            while (currNode != null) {
                nextNode = currNode.next;
                currNode.next = prevNode;
                prevNode = currNode;
                currNode = nextNode;
            }
            return prevNode;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.