在最后一步拆分链表那里始终想不通问题在哪里,求解惑 /* public class RandomListNode { int label; RandomListNode next = null; RandomListNode random = null; RandomListNode(int label) { this.label = label; } } */ public class Solution { public RandomListNode Clone(RandomListNode pHead){ if(pHead==null){ return null; } RandomListNode curNode=pHead; while(curNode!=null){ RandomListNode cloneNode=new RandomListNode(curNode.label); cloneNode.next=curNode.next; curNode.next=cloneNode; curNode=curNode.next.next; } curNode=pHead; while(curNode!=null){ if(curNode.random!=null){ curNode.next.random=curNode.random.next; } curNode=curNode.next.next; } /* 这块有问题。。。最后输出为空 */ curNode=pHead; RandomListNode pCloneHead=pHead.next; RandomListNode curClone=curNode.next; while(curClone.next!=null){ curNode.next=curNode.next.next; curNode=curClone.next; curClone.next=curClone.next.next; curClone=curClone.next; } return pCloneHead; } }