由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - palantir 面经
相关主题
分享:non-recursive breadth first search and depth first search algorithm in Cinterview心得:我是如何做到bug free的
Palantir面经一道google面经难题
uber 电面面经求16暑期实习内推
求问一题G家的面经bfs vs dfs
shortest path in matrixbloomberg onsite & offer
Palantir新鲜面经一道面试题
Palantir Internship 面经请教一个二叉树镜像问题
郁闷的求职过程请教一道面试题
相关话题的讨论汇总
话题: thing话题: ptr话题: ans话题: return话题: struct
进入JobHunting版参与讨论
1 (共1页)
e***n
发帖数: 68
1
struct Thing {
int length;
struct Thing *things[];
};
/* Return a deep copy of thing. The object graph formed by the copy
* should have the same structure as the object graph of the original,
* but they should share no references.
*/
l********5
发帖数: 230
2
应该还是要考虑各种case。。。palantir很喜欢细节。。很想testing的题。。。
a********x
发帖数: 1502
3
http://www.leetcode.com/2012/05/clone-graph-part-i.html
very similar, I think

【在 e***n 的大作中提到】
: struct Thing {
: int length;
: struct Thing *things[];
: };
: /* Return a deep copy of thing. The object graph formed by the copy
: * should have the same structure as the object graph of the original,
: * but they should share no references.
: */

K*********n
发帖数: 2852
4
牛,这公司理你了啊,他们据说挺拽啊

【在 e***n 的大作中提到】
: struct Thing {
: int length;
: struct Thing *things[];
: };
: /* Return a deep copy of thing. The object graph formed by the copy
: * should have the same structure as the object graph of the original,
: * but they should share no references.
: */

e***n
发帖数: 68
5
不知道阿。。。反正面我的老美开着免提也

【在 K*********n 的大作中提到】
: 牛,这公司理你了啊,他们据说挺拽啊
q****m
发帖数: 177
6
先简化一下 比如如何 deep copy
struct Thing{
int length,
struct Thing *next;
}
吧,这个 deep copy就相当于重新 create一个 linked list

【在 e***n 的大作中提到】
: struct Thing {
: int length;
: struct Thing *things[];
: };
: /* Return a deep copy of thing. The object graph formed by the copy
: * should have the same structure as the object graph of the original,
: * but they should share no references.
: */

p*****2
发帖数: 21240
7
DFS就可以了吧。
l***i
发帖数: 1309
8
随便写了一个,大牛指点
Thing* deepCopy(Thing *ptr)
{
if (ptr == NULL) return NULL;
Thing *ans = new Thing;
ans->length = ptr->length;
for (int i=0; i ans->things[i] = deepCopy(ptr->things[i]);
return ans;
}
d*********g
发帖数: 154
9

貌似遇到circle就无限循环了

【在 l***i 的大作中提到】
: 随便写了一个,大牛指点
: Thing* deepCopy(Thing *ptr)
: {
: if (ptr == NULL) return NULL;
: Thing *ans = new Thing;
: ans->length = ptr->length;
: for (int i=0; i: ans->things[i] = deepCopy(ptr->things[i]);
: return ans;
: }

l***i
发帖数: 1309
10
有道理。再想想。搞个map记录已经见过的node
Thing* deepCopy(Thing *ptr, map &mp)
{
if (ptr == NULL) return NULL;
if (mp.find(ptr) != mp.end()) return mp[ptr];
Thing *ans = new Thing; mp[ptr] = ans;
ans->length = ptr->length;
for (int i=0; i ans->things[i] = deepCopy(ptr->things[i]);
return ans;
}
l***i
发帖数: 1309
11
嗯,刚刚看了leetcode的答案贴,思路差不多
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教一道面试题shortest path in matrix
刚刚电面bloomberg,被问到一个没看到过的问题Palantir新鲜面经
神奇的一天,两据信+一个offerPalantir Internship 面经
Palantir新鲜面经郁闷的求职过程
分享:non-recursive breadth first search and depth first search algorithm in Cinterview心得:我是如何做到bug free的
Palantir面经一道google面经难题
uber 电面面经求16暑期实习内推
求问一题G家的面经bfs vs dfs
相关话题的讨论汇总
话题: thing话题: ptr话题: ans话题: return话题: struct