Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

reverse linkedlist

class Solution {
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;  
        ListNode current = head;
    
        
        while(current != null) { 
            ListNode next = current.next; 
            current.next = prev;
            prev = current;
            current = next;
        }
       return prev; 
    }
}
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #reverse #linkedlist
ADD COMMENT
Topic
Name
4+3 =