920的这些accessories实在是碉堡了# PDA - 掌中宝
s*h
1 楼
贡献一点面经.
我准备的时间还不够, 今天这二面有点忐忑.面我的人是个白人小伙子, 说话很快, 不
停的提附加问题.
1. how to pick first k maximum numbers in an array.
me: most straightforward, sort then pick, nlgn + k
he: ok...
me: better way, quick select, n * k
he: what is quick select, why is it linear time?
me: talking...
he: what if array is way bigger than the memory, can this work?
me:...yes...but slower due to swapping...
he: anything better?
me: ...
我不太明白他想问什么,所以没答上这一问,最后他问我有什么问题的时候我就
问了他,他说,你可以构造一个size k heap. then it is nlogk. 哎, 我当时真
没往这想. 还是准备不够.
2. write a c program to reverse a string, read to me.
me: reading...
he: how do you test? what parameter will you pass to it?
me: char *, but can't be string literal
he: what is string literal? why can't?
me: talking...
he: what if there are unexpected results, say garbage char?
me: ..? the trailing \0 is not right after the valid char?
he: no, let's say they use this to sort german, and garbage char.
me: it should work?
he: what is char set of german?
me: oh, you are talking about unicode, 2 bytes per char?
he: what would that affect your program?
me: just swap 2 bytes instead of 1 then.
he: ok...
3. design a card game in c++
这个题很无聊,我也不玩牌,只好一边想一边写,
class card
{
...
int suit,
int rank,
...
}
class app
{
struct { card mycard,
card * next;
}
...
}
这个不work,而且实际很傻,把next定义在card里不就完了.
当然他就问了,说你这个如果超过两张不就不行了,我才发现
card里面需要有个 card * next, 我跟他说了他就ok了.
4. explain mutex & deadlock, how to avoid deadlock.
这个标准概念题. 然后我们讨论了下第一题的那个heap. 之后就挂了,
刚好一小时. 他说如果有下一轮,那么可能是onsite.
不知道吉凶如何. 心里七上八下. 不过还是自己准备的时间太短.
过一段应该状态有提升. 诸位有人这些天拿到他们的onsite吗?
我准备的时间还不够, 今天这二面有点忐忑.面我的人是个白人小伙子, 说话很快, 不
停的提附加问题.
1. how to pick first k maximum numbers in an array.
me: most straightforward, sort then pick, nlgn + k
he: ok...
me: better way, quick select, n * k
he: what is quick select, why is it linear time?
me: talking...
he: what if array is way bigger than the memory, can this work?
me:...yes...but slower due to swapping...
he: anything better?
me: ...
我不太明白他想问什么,所以没答上这一问,最后他问我有什么问题的时候我就
问了他,他说,你可以构造一个size k heap. then it is nlogk. 哎, 我当时真
没往这想. 还是准备不够.
2. write a c program to reverse a string, read to me.
me: reading...
he: how do you test? what parameter will you pass to it?
me: char *, but can't be string literal
he: what is string literal? why can't?
me: talking...
he: what if there are unexpected results, say garbage char?
me: ..? the trailing \0 is not right after the valid char?
he: no, let's say they use this to sort german, and garbage char.
me: it should work?
he: what is char set of german?
me: oh, you are talking about unicode, 2 bytes per char?
he: what would that affect your program?
me: just swap 2 bytes instead of 1 then.
he: ok...
3. design a card game in c++
这个题很无聊,我也不玩牌,只好一边想一边写,
class card
{
...
int suit,
int rank,
...
}
class app
{
struct { card mycard,
card * next;
}
...
}
这个不work,而且实际很傻,把next定义在card里不就完了.
当然他就问了,说你这个如果超过两张不就不行了,我才发现
card里面需要有个 card * next, 我跟他说了他就ok了.
4. explain mutex & deadlock, how to avoid deadlock.
这个标准概念题. 然后我们讨论了下第一题的那个heap. 之后就挂了,
刚好一小时. 他说如果有下一轮,那么可能是onsite.
不知道吉凶如何. 心里七上八下. 不过还是自己准备的时间太短.
过一段应该状态有提升. 诸位有人这些天拿到他们的onsite吗?