标签:
链表数据结构
public class ListNode { public int val; public ListNode next; public ListNode(int x) { val = x; } }
反转代码
public ListNode reverse(ListNode head) { ListNode p; ListNode tmp = head.next; head.next = null; while(tmp != null) { p = tmp; tmp = tmp.next; p.next = head; head = p; } return head;
}
标签:
原文地址:http://www.cnblogs.com/shizhh/p/4642341.html