My AC java Solution


  • 1
    J
    public class Solution {
        public ListNode reverseList(ListNode head) {
        
         ListNode pre = null;
         ListNode cur = head;
         ListNode next;
        
         while(cur!=null)
         {
        	 next= cur.next;
        	 cur.next= pre;
        	 pre = cur;
        	 cur = next;
        	 
         }
         return pre;
         
    	}
    
    }

Log in to reply
 

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