avatar
l*h
1
做手机的那个A,希望对同胞们有用。
每次都是两个人一起面,总共五六组,所以总共要见十个还是十二个。记得的问题:
1. Find the lonely celebrity(celebrity: everyone knows him, he knows no one)
. Given a function boolean knows(A, B), which tells you if A knows B.
Implement function: List getLonelyCelebrity(Set names).
2. You got 2^40 positive 4 byte integers on disk, 16M memory, how to find
the first missing integer.
3. Implement the merge of multiple inputs. (I assumed each input implements
hasNext(), next())
4. Reverse a byte array, Reverse a char array (variant length char)
5. A row of hosts, from left to right, find a method to calculate the total
number of hosts. Each host can invoke: isLeft, isRight, sendToLeft,
sendToRight.
6. On cellphone keyboard, each number corresponds to several chars. Given a
list numbers, e.g. 1224668332, find the longest valid word (dict is given).
7. Reverse a list in Java, complexity?
8. design: a remote service+DB to keep top 100 scores for a game. It's a
single player game, and played on mobile device. Requirement: every time an
user starts to play, show the current top 100 scores.
9. design: java process同步的问题, 一堆write process,一开始write process要共
同agree一个数,比如100,那么就产生100个文件。完了之后一堆read process开始,去
consume这些文件。
10. 一个permutation相关的问题,记不得细节了
avatar
b*7
2
celebrity的题最近很常见啊,
社会名流算法,练习下
vector getLonelyCelebrity(vector names)
{
vector celebrities;
if(names.empty()) return celebrities;
int i = 0, j = names.size()-1;
while(i < j)
{
if(knows(names[i],names[j]))
i++;
else
j--;
}
//check if i-th person is a celebrity
//1.he knows no one
for(int k = 0; k < names.size(); k++)
{
if(k != i && knows(names[i],names[k]))
return celebrities;//
}
//2.everybody knows him
for(int k = 0; k < names.size(); k++)
{
if(k != i && !knows(names[k],names[i]))
return celebrities;
}
celebrities.push_back(names[i]);
return celebrities;
}
avatar
r*e
3
既然返回值是vector,celebrity可能不止一个
你的做法是默认一个吧

【在 b******7 的大作中提到】
: celebrity的题最近很常见啊,
: 社会名流算法,练习下
: vector getLonelyCelebrity(vector names)
: {
: vector celebrities;
: if(names.empty()) return celebrities;
: int i = 0, j = names.size()-1;
: while(i < j)
: {
: if(knows(names[i],names[j]))

avatar
x*4
4
如果存在两个celebrity, 就与题目中要求(everyone knows him, he knows no one)
矛盾了

【在 r*******e 的大作中提到】
: 既然返回值是vector,celebrity可能不止一个
: 你的做法是默认一个吧

avatar
r*e
5
是的,默认应该是你这样理解
但是如果celebrity之间的关系不算的话,就不一样
只是觉得题目的返回值用vector有点奇怪

【在 x*******4 的大作中提到】
: 如果存在两个celebrity, 就与题目中要求(everyone knows him, he knows no one)
: 矛盾了

avatar
w*j
6
9怎么做? 什么pattern?
avatar
b*7
7
celebrity要么有一个,要么没有。给你这样的返回值可能是考察你是否想到这一点。

【在 r*******e 的大作中提到】
: 是的,默认应该是你这样理解
: 但是如果celebrity之间的关系不算的话,就不一样
: 只是觉得题目的返回值用vector有点奇怪

avatar
l*a
8
这个做手机的A还用java interview?

one)
implements

【在 l**h 的大作中提到】
: 做手机的那个A,希望对同胞们有用。
: 每次都是两个人一起面,总共五六组,所以总共要见十个还是十二个。记得的问题:
: 1. Find the lonely celebrity(celebrity: everyone knows him, he knows no one)
: . Given a function boolean knows(A, B), which tells you if A knows B.
: Implement function: List getLonelyCelebrity(Set names).
: 2. You got 2^40 positive 4 byte integers on disk, 16M memory, how to find
: the first missing integer.
: 3. Implement the merge of multiple inputs. (I assumed each input implements
: hasNext(), next())
: 4. Reverse a byte array, Reverse a char array (variant length char)

avatar
c*a
9
2个人面,压力大啊
avatar
l*h
10
对, 是考点之一。

【在 b******7 的大作中提到】
: celebrity要么有一个,要么没有。给你这样的返回值可能是考察你是否想到这一点。
avatar
l*h
11
他们service那一块的,几乎全是Java.

【在 l*****a 的大作中提到】
: 这个做手机的A还用java interview?
:
: one)
: implements

avatar
c*t
12
多谢面经!
你面的时候确认了最多只有一个celebrity吗?

【在 l**h 的大作中提到】
: 对, 是考点之一。
avatar
c*t
13
你说的这种情况也不难解决,如果是
celebrity: everyone knows him, he knows only other celebrities
就复杂了。

【在 r*******e 的大作中提到】
: 是的,默认应该是你这样理解
: 但是如果celebrity之间的关系不算的话,就不一样
: 只是觉得题目的返回值用vector有点奇怪

avatar
c*t
14
5 能不能再解释一下, 不懂isRight, sendLeft要做什么。

one)
implements

【在 l**h 的大作中提到】
: 做手机的那个A,希望对同胞们有用。
: 每次都是两个人一起面,总共五六组,所以总共要见十个还是十二个。记得的问题:
: 1. Find the lonely celebrity(celebrity: everyone knows him, he knows no one)
: . Given a function boolean knows(A, B), which tells you if A knows B.
: Implement function: List getLonelyCelebrity(Set names).
: 2. You got 2^40 positive 4 byte integers on disk, 16M memory, how to find
: the first missing integer.
: 3. Implement the merge of multiple inputs. (I assumed each input implements
: hasNext(), next())
: 4. Reverse a byte array, Reverse a char array (variant length char)

avatar
l*h
15


【在 c********t 的大作中提到】
: 多谢面经!
: 你面的时候确认了最多只有一个celebrity吗?

avatar
l*h
16
isRight: 返回当前host是不是最右边的host
sendLeft: 发送一个消息给左边的host.
最后要通过消息传递来统计总host数

【在 c********t 的大作中提到】
: 5 能不能再解释一下, 不懂isRight, sendLeft要做什么。
:
: one)
: implements

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