avatar
Google onsite归来# JobHunting - 待字闺中
T*7
1
☆─────────────────────────────────────☆
judyzx (judy) 于 (Mon Jun 15 17:00:59 2009, 美东) 提到:
各位慢慢看,前面是今天的故事,8楼是自己对问题的分析。B是我lg.没想到写了那么长。
我还没有和家里人商量,怕刺激到他们,家里人都觉得我们两都好好的。但是事实不是
这样的。
周末B要我陪他加班.我不喜欢,但是为了他高兴,就去了.
在那里看书,很闷.待着一点没有意思,又不能走动,也不能说话,而且有点感冒想早点
回来.待了大概3个多小时的时候说要回家.
我说了你老是让我陪你加班,我那里很没意思.而且我今天不舒服.这时候还挺好的,b说
那以后不让你陪着加班了.
b说要去中国城,(看上去兴致挺高的样子)我说跑这么远去一次也没有什么意思.而且那
个地方那么破。他有点郁闷,说,那就回去吧.
后来到了门口,他不愿意上去,说要去转转,我赌气说那我也去,否则我没地吃饭去.平时5
天每天我做的饭,周末我和他说让他负责,否则我满脑子都是每天做什么吃.
再后来,在开往中国城的路上,都一大半了.好像我们又说了些什么,后来他
avatar
D*g
2
面经回馈本版,只列出technical question.
P1:
A. Add next pointer to each node on a BTree to its next sibling on the same
level.
B. Boggle题,find all possible words from a 2D character array.
P2:
A. Given
interface Iterator {
T next();
boolean hasNext();
}
interface Predicate {
boolean accept(T t);
}
Implement a method that creates an "accept" iterator that returns items
accepted by the passedin pred variable.
Iterator conditionIterator(Iterator input, Predicate pred) {
}
B. Concurrent programming.
P3:
Find # of elements that are equal to a given value in a sorted array. O(lgn)
solution. O(n) solution is not good enough.
P4:
Design and implement a class to train from a input string like "ape apple
ace" to generate new words based on conditional probability of P(c_i|c_j).
e.g., P(p|a), P(e|p), P(l|p).
class TokenGenerator {
public void train(String t) {...}
public String generate() {...}
}
How to optimize generate() method.
P5:
A. Given an input string and an order string, e.g., "house" and "soup",
print out characters in input string according to character order in output
string. For characters in input string but not in output string, output them
in the end, their relative order doesn't matter.
So for "house", "souhe" and "soueh" are valid outputs.
B. Design Google suggests.
avatar
a*o
3
楼主是不是dm的phd?
有道train的题目没看懂。。。

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
d*u
4
bless! Thanks for sharing
avatar
H*y
5
bless

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
p*2
6
多些分享。
avatar
p*2
7
P2A没看懂。
avatar
f*t
8
bless
avatar
g*y
9
Google suggest那个你怎么答的?我也被问过,回答得一塌糊涂。
avatar
c*p
10
Big Bless!

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
w*y
11
thx and bless!!!!
avatar
D*g
12
updated questions to clarify.
avatar
i*e
13
bless and 赞。
B. Concurrent programming.
这是问的什么问题呢?
avatar
p*p
14
bless you!
avatar
w*x
15
3个基础题都不难, data mining的题一个都不会
楼主肯定是data mining的phd??
avatar
w*y
16
Boggle题,find all possible words from a 2D character array.
这是什么样的题目? 能具体说说么? 看样子是老题, 但是我没见过//囧
avatar
w*y
17
java里面的iterator, 怎么还有专门问java的题目?
当然c++的iterator从来没用过//汗

【在 p*****2 的大作中提到】
: P2A没看懂。
avatar
w*y
18
P5:A. 我也完全看懵了....... 这题想考什么呀? 因为我有一个很圡的法子
1. 把input string的char做一个set
2. 一个 dupSet, 刚开始为空
3. scan order string
出现在set OR dupSet里面的char,
print,
set.remove,
dupSet.add
4. scan完order string之后,如果set不为空, 就把剩下的都打印出来
可是这出题的本意是什么呀?
avatar
z*g
19
谢谢! 我本来不会的,被你这么一写,感觉不算难啊。
我有一个问题,如果iterator的用户不停调用next,而不用hasNext,怎么处理。
这算是需要考虑的问题吗?
谢谢!

【在 w***y 的大作中提到】
: java里面的iterator, 怎么还有专门问java的题目?
: 当然c++的iterator从来没用过//汗

avatar
z*g
20
一起请教concurrent programming的具体内容。
avatar
p*2
21

用DFS,其实写起来也不算很容易。
从每个点开始做DFS,找单词。

【在 w***y 的大作中提到】
: Boggle题,find all possible words from a 2D character array.
: 这是什么样的题目? 能具体说说么? 看样子是老题, 但是我没见过//囧

avatar
w*y
22
我写的不对, 所以删掉了
你说的就是这个出题的point, 这些都要考虑

【在 z**********g 的大作中提到】
: 谢谢! 我本来不会的,被你这么一写,感觉不算难啊。
: 我有一个问题,如果iterator的用户不停调用next,而不用hasNext,怎么处理。
: 这算是需要考虑的问题吗?
: 谢谢!

avatar
p*2
23

需要考虑。

【在 z**********g 的大作中提到】
: 谢谢! 我本来不会的,被你这么一写,感觉不算难啊。
: 我有一个问题,如果iterator的用户不停调用next,而不用hasNext,怎么处理。
: 这算是需要考虑的问题吗?
: 谢谢!

avatar
w*y
24
okok
那这种题目是不是有个dictionary, 好知道哪些是valid words?
做DFS的时候也是从valid starting char开始?
写起来貌似很多麻烦, 我把题目搞清楚了要写写看

【在 p*****2 的大作中提到】
:
: 需要考虑。

avatar
z*g
25
boggle 那题 dfs + tire 就好了。
请教 iterator + predicate 那题。
avatar
p*2
26

我写了一个。
Iterator it=null;
Predicate pr=null;
T next=null;
Iterator conditionIterator(Iterator input, Predicate pred)
{
it=input;
pr=pred;
hasNext();
}
T next()
{
T ret=next;
hasNext();
return ret;
}
T hasNext()
{
if(next==null)
{
while(it.hasNext())
{
next=it.hasNext();
if(pr.accept(next))
break;
else
next=null;
}
}
return next!=null;
}

【在 w***y 的大作中提到】
: 我写的不对, 所以删掉了
: 你说的就是这个出题的point, 这些都要考虑

avatar
p*2
27

应该是有个字典,你能够查是不是有效单词。至于字典是hashtable还是trie无所谓。
不是考察重点。

【在 w***y 的大作中提到】
: okok
: 那这种题目是不是有个dictionary, 好知道哪些是valid words?
: 做DFS的时候也是从valid starting char开始?
: 写起来貌似很多麻烦, 我把题目搞清楚了要写写看

avatar
w*y
28
找到一个答案
http://code.vith.me/2011/05/finding-words-in-2d-character-array
面试的时候竟然要写这么多code!!!!!!!

【在 p*****2 的大作中提到】
:
: 应该是有个字典,你能够查是不是有效单词。至于字典是hashtable还是trie无所谓。
: 不是考察重点。

avatar
z*g
30
Great!
But I think the next function should be
T next()
{
hasNext();
T ret = next;
next = null;
return ret;
}

【在 p*****2 的大作中提到】
:
: 所以说这题不算容易写。

avatar
i*e
31
那个链接好像是找 crossword 解,跟 boggle 不一样。
boggle 是每个字都可以往 8 个方向转,而crossword不行。

【在 w***y 的大作中提到】
: 找到一个答案
: http://code.vith.me/2011/05/finding-words-in-2d-character-array
: 面试的时候竟然要写这么多code!!!!!!!

avatar
p*2
32

不用吧?next总是应该return的item,直接return就可以了。不需要调hasNext()

【在 z**********g 的大作中提到】
: Great!
: But I think the next function should be
: T next()
: {
: hasNext();
: T ret = next;
: next = null;
: return ret;
: }

avatar
z*g
33
In your original implementation, if the user call next() after
initialization, it will return null, right?

【在 p*****2 的大作中提到】
:
: 不用吧?next总是应该return的item,直接return就可以了。不需要调hasNext()

avatar
p*2
34

constructor里边调了hasnext了。

【在 z**********g 的大作中提到】
: In your original implementation, if the user call next() after
: initialization, it will return null, right?

avatar
z*g
35
sorry, I missed it. but you still need to set next = null before hasNext()
in next(), right?

【在 p*****2 的大作中提到】
:
: constructor里边调了hasnext了。

avatar
p*2
36


sorry, I missed it. but you still need to set next = null before hasNext()
in next(), ri........
★ Sent from iPhone App: iReader Mitbbs Lite 7.51

【在 z**********g 的大作中提到】
: sorry, I missed it. but you still need to set next = null before hasNext()
: in next(), right?

avatar
L*k
37
zan!

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
b*g
38
我的理解是每次都预读一个next, 然后就ok 了
Iterator it = null;
Predicate pr = null;
T next =null;
Iterator conditionIterator(Iterator input, Predicate pred)
{
it = input;
pr = pred;
next();
}
T next() {
T ret = next;
bool found = false;
while(it.hasNext()) {
T val = it.next();
if(pr.accept(val)){
next = val;
found = true;
break;

}
if(!found) next = NULL;
return ret;
}
bool hasnext() {
return !next;
}

【在 p*****2 的大作中提到】
: 对
:
: sorry, I missed it. but you still need to set next = null before hasNext()
: in next(), ri........
: ★ Sent from iPhone App: iReader Mitbbs Lite 7.51

avatar
b*g
39
为什么不BFS?

【在 p*****2 的大作中提到】
: 对
:
: sorry, I missed it. but you still need to set next = null before hasNext()
: in next(), ri........
: ★ Sent from iPhone App: iReader Mitbbs Lite 7.51

avatar
p*2
40

感觉不太合适。没怎么多想。感觉DFS很直接的思路。

【在 b********g 的大作中提到】
: 为什么不BFS?
avatar
d*y
41
这位童鞋你不想要offer了吗 回来就上题 啊?

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
d*y
42
这位童鞋你不想要offer了吗 回来就上题 啊?

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
g*y
43
不要这么说,不管哪种方式,互相帮助找工都是好的。祝福楼主拿到。

【在 d*****y 的大作中提到】
: 这位童鞋你不想要offer了吗 回来就上题 啊?
:
: same

avatar
z*g
44
回答一下如何design google suggest. 抛砖引玉。
我想基本的structure应该是trie + minheap.
First, we need to assume that popular search phases' search frequencies are
known. I think this can be achieved by map reduce easily, and the result is
stored at a database called DB.
Then, build a trie according to those popular search phases. Each node in
the trie has a pointer to a minHeap. The minHeap has a fixed size of 10.
Each node in minHeap stores a word and its frequency.
Suppose we want to insert a word craigslist into the trie, we need to update
every node's minHeap along the path, namely c, cr, cra, crai, craig, craigs
, craigsl, cragisli, cragislis and craigslist.
Please note this approach builds the trie according to DB statically,
and I think we need to reconstruct a new trie according to new DB every
month.
avatar
j*9
45
bless
avatar
l*d
46
参照 peking2 的写了一个:
public Iterator conditionIterator(final Iterator input,
final Predicate pred) {
return new Iterator() {
T next = null;
public T next() {
if (!hasNext()) throw new NoSuchElementException("no more element");
T ret = next;
next = null;
return ret;
}
public boolean hasNext() {
if (next != null) return true;
else if (!input.hasNext()) return false;
else {
next = input.next();
while (!pred.accept(next) && input.hasNext()) {
next = input.next();
}
if (pred.accept(next)) return true;
else {
next = null;
return false;
}
}
}
};
}
avatar
g*y
47
方向不对,他们关心的是大规模数据,每时每刻都有新的数据进来,这些东西不能保存
在一台机器上,计算不可能实时同步,但是又不能滞后太多。而且你需要把历史数据和
当前热点都考虑进去。然后全球时差,中国发生大事时,美国可能在睡觉,所以需要
roll along时区。这是G的architect这么跟我提的几点。当然那些什么edit distance,
字/词匹配也是要考虑的。
我当时听着就心想,谁要是不做这个方向,能考虑全这些方面,也太神了。

are
is
update
craigs

【在 z**********g 的大作中提到】
: 回答一下如何design google suggest. 抛砖引玉。
: 我想基本的structure应该是trie + minheap.
: First, we need to assume that popular search phases' search frequencies are
: known. I think this can be achieved by map reduce easily, and the result is
: stored at a database called DB.
: Then, build a trie according to those popular search phases. Each node in
: the trie has a pointer to a minHeap. The minHeap has a fixed size of 10.
: Each node in minHeap stores a word and its frequency.
: Suppose we want to insert a word craigslist into the trie, we need to update
: every node's minHeap along the path, namely c, cr, cra, crai, craig, craigs

avatar
z*c
48
说个我原来G电面类似题面试官告诉我要注意的地方。。
next不能设为null,因为他提示我iterator给的值可能是null,然后pred可能null的返
回是true
所以这样对于T的假设是错误的,NULL对调用者可能是有意义的
正确的方法是设一个validNext的bool,看next是不是刚从iterator里拿出来的

【在 p*****2 的大作中提到】
:
: 感觉不太合适。没怎么多想。感觉DFS很直接的思路。

avatar
J*F
49
请问edit distance 和这个search suggestion 有什么关系?

distance,

【在 g**********y 的大作中提到】
: 方向不对,他们关心的是大规模数据,每时每刻都有新的数据进来,这些东西不能保存
: 在一台机器上,计算不可能实时同步,但是又不能滞后太多。而且你需要把历史数据和
: 当前热点都考虑进去。然后全球时差,中国发生大事时,美国可能在睡觉,所以需要
: roll along时区。这是G的architect这么跟我提的几点。当然那些什么edit distance,
: 字/词匹配也是要考虑的。
: 我当时听着就心想,谁要是不做这个方向,能考虑全这些方面,也太神了。
:
: are
: is
: update

avatar
g*y
50
用户的输入不是完美的,很可能多/错/漏一个字母,所以计算输入的时候,通常会考虑
edit distance = 1范围内的其它词。你试试google suggest就知道了。

【在 J**F 的大作中提到】
: 请问edit distance 和这个search suggestion 有什么关系?
:
: distance,

avatar
J*F
51
明白你的意思了,这个想法很正确。
如果面试的时候能把这个也说出来应该还是很加分的 :)

【在 g**********y 的大作中提到】
: 用户的输入不是完美的,很可能多/错/漏一个字母,所以计算输入的时候,通常会考虑
: edit distance = 1范围内的其它词。你试试google suggest就知道了。

avatar
h*g
52
P2 这题是啥意思?谁能帮忙解释一下,最好给个例子

same

【在 D********g 的大作中提到】
: 面经回馈本版,只列出technical question.
: P1:
: A. Add next pointer to each node on a BTree to its next sibling on the same
: level.
: B. Boggle题,find all possible words from a 2D character array.
: P2:
: A. Given
: interface Iterator {
: T next();
: boolean hasNext();

avatar
p*2
53

学习了。

【在 z********c 的大作中提到】
: 说个我原来G电面类似题面试官告诉我要注意的地方。。
: next不能设为null,因为他提示我iterator给的值可能是null,然后pred可能null的返
: 回是true
: 所以这样对于T的假设是错误的,NULL对调用者可能是有意义的
: 正确的方法是设一个validNext的bool,看next是不是刚从iterator里拿出来的

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。