链表逆序
public ListNode reverseList(ListNode head){ ListNode newHead = new ListNode(); while(head!=null){ ListNode next = head.next; head.next = newHead.next; newHead.next = head; head = next; } return newHead.next; }
public ListNode reverseList(ListNode head){ ListNode newHead = new ListNode(); while(head!=null){ ListNode next = head.next; head.next = newHead.next; newHead.next = head; head = next; } return newHead.next; }