思路
首先不要直接新建链表,而是把以前的利用起来
而是需要注意顺序
相当于利用头插法,把A插到新的链表上,而不需要新申请空间。
下面在调整链接是一定注意
正确的代码
ListNode p = head;
head = head.next;
p.next = null;
错误的代码
ListNode p = head;
p.next = null;
head = head.next;