Redian新闻
>
Re: 【承诺凡顶贴到偶数页即奔一张新照片】!~
avatar
Re: 【承诺凡顶贴到偶数页即奔一张新照片】!~# PhotoGear - 摄影器材
e*s
1
Copy List with Random Pointer
A linked list is given such that each node contains an additional random
pointer which could point to any node in the list or null.
Return a deep copy of the list.
下面注释里面是别人写的能跑过的 上面的是我的 到现在都改得几乎一模一样了
可是还是超时
/**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), random(NULL) {}
* };
*/
class Solution {

public:
RandomListNode *copyRandomList(RandomListNode *head) {

unordered_map myMap;

if (NULL == head) return NULL;

RandomListNode* myhead = NULL;

DFS(head,myhead,myMap);

return myhead;

}

void *DFS(RandomListNode *DFSOldHead, RandomListNode *&DFSMyHead,
unordered_map DFSmyMap){

if (NULL == DFSOldHead) return NULL;

DFSMyHead = new RandomListNode(DFSOldHead->label);

if( DFSmyMap.find(DFSOldHead) == DFSmyMap.end() ){

DFSmyMap[DFSOldHead] = DFSMyHead;

}

if (DFSOldHead -> next){

if (DFSmyMap.end() == DFSmyMap.find(DFSOldHead -> next)){

DFS(DFSOldHead -> next, DFSMyHead->next, DFSmyMap);

}

else{

DFSMyHead -> next = DFSmyMap[DFSOldHead -> next];
}
}

if (DFSOldHead -> random){

if (DFSmyMap.end() == DFSmyMap.find(DFSOldHead -> random)){

DFS(DFSOldHead -> random, DFSMyHead->random, DFSmyMap);

}
else{

DFSMyHead -> random = DFSmyMap[DFSOldHead -> random];

}

}

}

};
/*
class Solution {
public:
RandomListNode *copyRandomList(RandomListNode *head) {
// Note: The Solution object is instantiated only once and is reused
by each test case.
if( head==NULL ) return NULL;
RandomListNode* newHead = NULL;
unordered_map< RandomListNode*, RandomListNode* > occur;
dfs( newHead, head, occur );
return newHead;
}
void dfs( RandomListNode*&cur, RandomListNode* node, unordered_map<
RandomListNode*, RandomListNode* >& occur ){
if( node==NULL ) return;
cur = new RandomListNode( node->label );
if( occur.find(node) == occur.end() ){
occur[node] = cur;
}
if( node->next ){
if( occur.find(node->next)==occur.end() ){
dfs( cur->next, node->next, occur );
}else{
cur->next = occur[node->next];
}
}
if( node->random ){
if( occur.find(node->random)==occur.end() ){
dfs( cur->random, node->random, occur );
}else{
cur->random = occur[node->random];
}
}
}
};
*/
avatar
m*e
2
上周五的等了好几个月的140突然变成RFE了。一般从收到RFE寄出材料之后到批准要再
额外花多久呢?RFE寄了材料后就可以马上加急吗?
avatar
l*a
3
【 以下文字转载自 Fashion 讨论区 】
发信人: hhhhhhhhhh (hhhhhhhhhh), 信区: Fashion
标 题: Re: 【承诺凡顶贴到偶数页即奔一张新照片】!~
发信站: BBS 未名空间站 (Sun Dec 26 00:43:03 2010, 美东)
请YS19和Sarah2008不要恶意灌水和顶贴,谢谢。
楼上 szxiami 请注意良好地语言和网络环境。我们互相尊重是前提,你说呢?谢谢
如约奔第21张照片
avatar
e*s
4
这么快就沉了。。
up

【在 e*******s 的大作中提到】
: Copy List with Random Pointer
: A linked list is given such that each node contains an additional random
: pointer which could point to any node in the list or null.
: Return a deep copy of the list.
: 下面注释里面是别人写的能跑过的 上面的是我的 到现在都改得几乎一模一样了
: 可是还是超时
: /**
: * Definition for singly-linked list with a random pointer.
: * struct RandomListNode {
: * int label;

avatar
F*u
5
一般回复了RFE 没问题的话很快就会批
我觉得没必要再pp了

【在 m********e 的大作中提到】
: 上周五的等了好几个月的140突然变成RFE了。一般从收到RFE寄出材料之后到批准要再
: 额外花多久呢?RFE寄了材料后就可以马上加急吗?

avatar
m*s
6
ccd有问题了吧
avatar
m*e
7
哦,好的,多谢多谢!
avatar
y*0
8
我当时是补交材料后一个星期批了。
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。