这个题没啥好说的,应该都能看懂
(在牛客题解区这个题还有更复杂的做法,这个题的本意应该就是用那种比较麻烦的方法做的,但是我觉得没啥必要)
/*function RandomListNode(x){
this.label = x;
this.next = null;
this.random = null;
}*/
function Clone(pHead)
{
if(pHead == null)return null;
var q = new RandomListNode(pHead.label);
q.random = pHead.random;
q.next = Clone(pHead.next)
return q;
}
//偷偷试过发现其实直接return也能过这个题,看来牛客的系统健壮性有待加强