C# Solution


  • 0
    public class Solution {
        public ListNode ReverseList(ListNode head) {
            
            ListNode current = head;
            ListNode head2 = null;
            while (current != null)
            {
                ListNode node = new ListNode(current.val);
                node.next = head2;
                current = current.next;
                head2 = node;
            }
            
            return head2;
            
        }
    }
    

Log in to reply
 

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