Standard and Easy Java Solution


  • 0
    M
    public ListNode reverseList(ListNode head) {
    
    	if (head == null)
    		return head;
    	ListNode current = head.next, next;
    	head.next = null;
    	while (current != null) {
    		next = current.next;
    		current.next = head;
    		head = current;
    		current = next;
    	}
    	return head;
    
    }

Log in to reply
 

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