由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - fb 面经
相关主题
这道题怎么做?现在面试可以用Java8吗?
问个电面题facebook 一面
一道google 题,谁给翻译一下意思,多谢。facebook的buffet puzzle
Amazon, too.求facebook puzzle的测试文件
salary increase within local job changefacebook HR电面让作puzzle,有谁有类似经验吗?
Amazon interview question.(4)facebook面试大概是个什么流程?
从王垠的代码看似乎其没在正规公司呆过 (转载)报一个facebook的offer,晚点补上面经
问一道google的题请教关于 F的电面
相关话题的讨论汇总
话题: string话题: int话题: length话题: increasing话题: next
进入JobHunting版参与讨论
1 (共1页)
w*****x
发帖数: 374
1
刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
慢了.
电话面试:
Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
写个better running time, 然后写个只用constant memory的. 最后一个constant
memory有一点tricky, 提示是用bottom-up iteration.
西雅图Onsite:
赞FB的recruiter动作都很快, 电面完了第二天就邀请去西雅图office onsite. 这个
onsite只有一轮45分钟, 其实也就是个面对面的电话面试. 题目就是把一个JSON string打印
成人能看懂的格式. 比较tricky的地方就是escape character和quoted character.
Palo Alto Onsite:
西雅图Onsite完第二天就邀请去Palo Alto面试. 不过正好到了圣诞假期, 于是拖到一
月份. 话说他们包的那个Sheraton Palo Alto酒店实在不咋地, 后面就是Caltrain的铁轨,
噪音很大. 不过campus给人感觉不错, 遇上的人都nice, 而且看上去干劲十足. (和原来公司天
壤之别啊,呵呵) Onsite一共四轮, 每个45分钟, 面了两轮之后休息和HR共进午餐. 题目如下:
1. Generate next n strings according to the following pattern:
1 (this is the input string)
11 (1 one in the previous string)
21 (2 one's in the previous string)
1211 (1 two, 1 one)
111221 (1 one, 1 two, 2 one's)
312211 (3 one's, 2 two's, 1 one)
附加题: Proof whether there is an input string that can produce a
sequence that's strictly non-increasing in length.
2. BST每个level列印一行. 说几个test case.
3. Sort colors.
有个enum叫做Color {Red, White, Blue}, 一个神奇的method叫Color getColor(int)
能把int value对应到Color上. 然后给一个int array, 要求sort the array to the
order Red, White then Blue. 只能用constant memory. 如果两个数字都对应一种颜色,
这两个数字随便怎么排. 此题我觉得是整个面试中最tricky的一道了吧. 提示是如果只有两种颜色
如何sort.
4. 设计FB首页的news feed.
5. 两个sorted array, A里面有足够的剩余空间放B, merge A and B. Give test
cases.
6. 橄榄球每次得2分3分或者7分. 给一个总分, 打印出所有可能的composition. (其实
就是硬币找零)
i**9
发帖数: 351
2
waw, congratulations!
I********T
发帖数: 22
3
3. Sort colors.
有个enum叫做Color {Red, White, Blue}, 一个神奇的method叫Color getColor(int)
能把int value对应到Color上. 然后给一个int array, 要求sort the array to the
order Red, White then Blue. 如果两个数字都对应一种颜色, 这两个数字随便怎么排
. 此
题我觉得是整个面试中最tricky的一道了吧. 提示是如果只有两种颜色如何sort.
这个题是counting sort? 再建一个array来存储每个数对应什么颜色, 然后遍历原
array得到对应的颜色和每个颜色有几个,最后建个新int array把原array中的各个数
填进去
l***g
发帖数: 191
4
cong
w*****x
发帖数: 374
5

忘了说明一个要求是constant memory. counting sort不是constant memory, 因为
input
是array, 不是linked list. 我来把原题更新一下.

【在 I********T 的大作中提到】
: 3. Sort colors.
: 有个enum叫做Color {Red, White, Blue}, 一个神奇的method叫Color getColor(int)
: 能把int value对应到Color上. 然后给一个int array, 要求sort the array to the
: order Red, White then Blue. 如果两个数字都对应一种颜色, 这两个数字随便怎么排
: . 此
: 题我觉得是整个面试中最tricky的一道了吧. 提示是如果只有两种颜色如何sort.
: 这个题是counting sort? 再建一个array来存储每个数对应什么颜色, 然后遍历原
: array得到对应的颜色和每个颜色有几个,最后建个新int array把原array中的各个数
: 填进去

s*****G
发帖数: 1535
6
big cong big cong!!!!!!!!!
li4 hai4 a
y**********a
发帖数: 733
7
cong a
h***n
发帖数: 276
8
就是partition把

【在 I********T 的大作中提到】
: 3. Sort colors.
: 有个enum叫做Color {Red, White, Blue}, 一个神奇的method叫Color getColor(int)
: 能把int value对应到Color上. 然后给一个int array, 要求sort the array to the
: order Red, White then Blue. 如果两个数字都对应一种颜色, 这两个数字随便怎么排
: . 此
: 题我觉得是整个面试中最tricky的一道了吧. 提示是如果只有两种颜色如何sort.
: 这个题是counting sort? 再建一个array来存储每个数对应什么颜色, 然后遍历原
: array得到对应的颜色和每个颜色有几个,最后建个新int array把原array中的各个数
: 填进去

w*****x
发帖数: 374
9

嗯, 就是in place swap. 当时想了半天脑子才转过弯来搞了个2-pass处理三种颜色.

【在 h***n 的大作中提到】
: 就是partition把
w*****x
发帖数: 374
10
学会怎么发包子了, 但是只有六个, 已经全部奉上!
相关主题
Amazon interview question.(4)现在面试可以用Java8吗?
从王垠的代码看似乎其没在正规公司呆过 (转载)facebook 一面
问一道google的题facebook的buffet puzzle
进入JobHunting版参与讨论
S******n
发帖数: 1009
11
恭喜了

一定散尽家财.)
顺手投了个简历.
那时候工作很忙,
的puzzle交上去.
对, 估计running time太
break up无数次最后
y), 先写最简单的那种, 然后
最后一个constant

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

W*F
发帖数: 3941
12
什么是puzzle,弱问一下
c****o
发帖数: 41
13
恭喜楼主啦!!

.)
.
running time太
种, 然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

g*********s
发帖数: 1782
14
intermediate = meal, hard = buffet? two meals or one buffet?

.)
.
running time太
种, 然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

g*********s
发帖数: 1782
15
1. Generate next n strings according to the following pattern:
1 (this is the input string)
11 (1 one in the previous string)
21 (2 one's in the previous string)
1211 (1 two, 1 one)
111221 (1 one, 1 two, 2 one's)
312211 (3 one's, 2 two's, 1 one)
can u explain more about the rule? i'm lost.

.)
.
running time

种,
然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

w*****x
发帖数: 374
16

嗯. 做了两个meal. Buffet没pass

【在 g*********s 的大作中提到】
: intermediate = meal, hard = buffet? two meals or one buffet?
:
: .)
: .
: running time太
: 种, 然后

g*********s
发帖数: 1782
17
the problem in the phone is dp, just like Fibonacci?
2, 5, 6 are all classical.
4, i know little about web, so no comments. :)
1, i'm not sure about what rule the pattern follows. can u elaborate it?
3, in case of 2-color only, partition() in quicksort()? so for 3-color
case, u treat two colors as the same first, then distinguish them in the
2nd pass. avg time is O(N) while space O(1). is this good enough?

.)
.
running time

种,
然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

w*****x
发帖数: 374
18

1 (这个是initial string)
11 (表示上一个string里面有一个1)
21 (上一个string里面有两个1)
1211 (一个2,两个1)
111221 (一个1,一个2,两个1)
312211 (三个1,两个2,一个1)
就是把连续的相同的数字归纳到一起.

【在 g*********s 的大作中提到】
: 1. Generate next n strings according to the following pattern:
: 1 (this is the input string)
: 11 (1 one in the previous string)
: 21 (2 one's in the previous string)
: 1211 (1 two, 1 one)
: 111221 (1 one, 1 two, 2 one's)
: 312211 (3 one's, 2 two's, 1 one)
: can u explain more about the rule? i'm lost.
:
: .)

g*********s
发帖数: 1782
19

two "1" -> 21
one "2", one "1", not two "1". u have a typo here and that's why i get
lost. :) now i think i know the pattern. thx.

【在 w*****x 的大作中提到】
:
: 1 (这个是initial string)
: 11 (表示上一个string里面有一个1)
: 21 (上一个string里面有两个1)
: 1211 (一个2,两个1)
: 111221 (一个1,一个2,两个1)
: 312211 (三个1,两个2,一个1)
: 就是把连续的相同的数字归纳到一起.

g*********s
发帖数: 1782
20
btw, what's the solution to the extra question? it seems the input "1"
satisfies this property. is this related to np complexity/turing machine,
about the problem encoding?

【在 g*********s 的大作中提到】
:
: two "1" -> 21
: one "2", one "1", not two "1". u have a typo here and that's why i get
: lost. :) now i think i know the pattern. thx.

相关主题
求facebook puzzle的测试文件报一个facebook的offer,晚点补上面经
facebook HR电面让作puzzle,有谁有类似经验吗?请教关于 F的电面
facebook面试大概是个什么流程?Google面试题
进入JobHunting版参与讨论
j*****u
发帖数: 1133
21
lz power怎么算的:
最简单的是y--每次乘x?
better running time的是recursion + DP?
const space的是每次乘方?比如x^15=x^8 * x^4 * x^2 * x^1,但是有重复运算。
sort color的不算tricky,如果你看到过dutch flag的话,你看interviewer连flag的
颜色都没改:P

.)
.
running time太
种, 然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

g*********s
发帖数: 1782
22
我孤陋寡闻了。不错。不过反过来按quicksort的partition应该也能得个80分吧?

【在 j*****u 的大作中提到】
: lz power怎么算的:
: 最简单的是y--每次乘x?
: better running time的是recursion + DP?
: const space的是每次乘方?比如x^15=x^8 * x^4 * x^2 * x^1,但是有重复运算。
: sort color的不算tricky,如果你看到过dutch flag的话,你看interviewer连flag的
: 颜色都没改:P
:
: .)
: .
: running time太

i**********e
发帖数: 1145
23
For number 1, the problem of proving the statement sounds MORE interesting..
. hmm..
My solution using character pointer manipulation.
#include
using namespace std;
void printCharCounts(const char *in, char out[]) {
int count = 1;
char *pOut = out;
const char *pIn = in;
while (*pIn) {
if (*pIn == *(pIn+1)) {
count++;
} else {
*pOut++ = '0' + count;
*pOut++ = *pIn;
count = 1;
}
pIn++;
}
*pOut = '\0';
}
int main() {
char str[100] = "1";
char next[100];
int n = 10;
cout << "Initial string: " << str << endl;
for (int i = 0; i < n; i++) {
printCharCounts(str, next);
cout << next << endl;
strcpy(str, next);
}
}
一些常见面试题的答案与总结 -
http://www.ihas1337code.com
i**********e
发帖数: 1145
24
>>Proof whether there is an input string that can produce a
sequence that's strictly non-increasing in length.
One example of an input that produces sequence non-increasing in length is:
22,
since it will produce the next output of 22 infinitely.
Also, you can prove that for any k groups of numbers (a group consists only
the same consecutive numbers).
Assume group = { a1, a2, ... ak },
then the next group = { m1a1 m2a2 ... mkak }, a total of 2k length.
Since a1 != a2, a2 != a1 && a2 != a3, ... ak-1 != ak-2 && ak-1 != ak,
Then the minimum possible of numbers of the next next group must also yield
a total of k groups of numbers, which the length is also 2k, which is in non
-increasing order in length.
But, I doubt such sequence exists besides the input "22", anyone can verify?
一些常见面试题的答案与总结 -
http://www.ihas1337code.com
s*******t
发帖数: 248
25
I don't think your proof is correct.
For example, "123" -> "111213" ->"31121113".

only
yield

【在 i**********e 的大作中提到】
: >>Proof whether there is an input string that can produce a
: sequence that's strictly non-increasing in length.
: One example of an input that produces sequence non-increasing in length is:
: 22,
: since it will produce the next output of 22 infinitely.
: Also, you can prove that for any k groups of numbers (a group consists only
: the same consecutive numbers).
: Assume group = { a1, a2, ... ak },
: then the next group = { m1a1 m2a2 ... mkak }, a total of 2k length.
: Since a1 != a2, a2 != a1 && a2 != a3, ... ak-1 != ak-2 && ak-1 != ak,

J*********n
发帖数: 370
26
congs,能不能报一下offer的情况?
i**********e
发帖数: 1145
27
"Then the minimum possible of numbers of the next next group must also yield
a total of k groups of numbers, which the length is also 2k, which is in
non-increasing order in length."
The proof is for the case which yields the "minimum" possible of number
where the minimum length = 2*k can produce sequence length's in non-
increasing order. It doesn't mean the next sequence's length must be non-
increasing.
I might still be wrong though, correct me if I'm wrong.
Can LZ please share how to answer: "Proof whether there is an input string
that can produce a sequence that's strictly non-increasing in length.",
thanks!
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

【在 s*******t 的大作中提到】
: I don't think your proof is correct.
: For example, "123" -> "111213" ->"31121113".
:
: only
: yield

Z*****Z
发帖数: 723
28
what does "strictly non-increasing" mean anyway?

yield

【在 i**********e 的大作中提到】
: "Then the minimum possible of numbers of the next next group must also yield
: a total of k groups of numbers, which the length is also 2k, which is in
: non-increasing order in length."
: The proof is for the case which yields the "minimum" possible of number
: where the minimum length = 2*k can produce sequence length's in non-
: increasing order. It doesn't mean the next sequence's length must be non-
: increasing.
: I might still be wrong though, correct me if I'm wrong.
: Can LZ please share how to answer: "Proof whether there is an input string
: that can produce a sequence that's strictly non-increasing in length.",

i**********e
发帖数: 1145
29
Means the next sequence's length is less than or equal to current sequence's
length?
Hope I understand this right.

【在 Z*****Z 的大作中提到】
: what does "strictly non-increasing" mean anyway?
:
: yield

f**********o
发帖数: 793
30
恭喜, 谢谢详细的面经
相关主题
[合集] 没人回复,直接上板上讨论吧。如果违反版规希望斑竹删掉就是问个电面题
H1B拿到后,如果被公司layoff后可以到其它公司工作么一道google 题,谁给翻译一下意思,多谢。
这道题怎么做?Amazon, too.
进入JobHunting版参与讨论
w*****x
发帖数: 374
31

对, 但是可以利用binary representation避免重复运算实现constant space.
呵呵, 就是因为没看过dutch flag, 所以想了半天, 最后忽然开窍 :D

【在 j*****u 的大作中提到】
: lz power怎么算的:
: 最简单的是y--每次乘x?
: better running time的是recursion + DP?
: const space的是每次乘方?比如x^15=x^8 * x^4 * x^2 * x^1,但是有重复运算。
: sort color的不算tricky,如果你看到过dutch flag的话,你看interviewer连flag的
: 颜色都没改:P
:
: .)
: .
: running time太

w*****x
发帖数: 374
32
我感觉是我把题目记错了, interviewer问的应该是proof whether there is a string
that can produce a sequence strictly decreasing in length. 不是non-
increasing.
如果是non-increasing我也觉得除了"22"之外就没有了. 当时没有严格的证明strictly
decreasing不存在, 只是举了两个例子:
比如"111", 后面是"31", 然后是"1311". "31"就是最小的length.
"1111"(之前是"一百一十一个1", 之前是更多的1), 之后是"41", 然后"1411". 长度还是
在"41"是达到最小, 然后开始增加.
所以就算从无穷多的1开始, 最后会达到一个"xxxx1"的情况, 这时候长度最短, 然后就
开始增加
了.
还要感谢1337coder大侠, 你的网站真的对我帮助很大. 11月份去面google的时候有一
题就是大
侠解过的, 不过可惜我后面在其他题目上犯了低级错误没拿到offer...

length is:
only

【在 i**********e 的大作中提到】
: >>Proof whether there is an input string that can produce a
: sequence that's strictly non-increasing in length.
: One example of an input that produces sequence non-increasing in length is:
: 22,
: since it will produce the next output of 22 infinitely.
: Also, you can prove that for any k groups of numbers (a group consists only
: the same consecutive numbers).
: Assume group = { a1, a2, ... ak },
: then the next group = { m1a1 m2a2 ... mkak }, a total of 2k length.
: Since a1 != a2, a2 != a1 && a2 != a3, ... ak-1 != ak-2 && ak-1 != ak,

f****r
发帖数: 30
33
cong! thanks for sharing.

.)
.
running time太
种, 然后

【在 w*****x 的大作中提到】
: 刚拿到offer, 发面经回馈版面. (不知道怎么发包子, 会的人教一下, 一定散尽家财.)
: 一切起源于9月底, 发现facebook在西雅图开了office在招聘, 于是顺手投了个简历.
: Recruiter很快回复, 要求做两个中等或者难的puzzle再开始面试. 那时候工作很忙,
: 也就耽搁了. 一直拖到thanksgiving假期才腾出点时间做了两个中等的puzzle交上去.
: facebull也做了, 本地机器上运行都没问题, 但是评卷机器人老说不对, 估计running time太
: 慢了.
: 电话面试:
: Puzzle做完了就开始电面. 加州office的人打电话过来, 信号不好break up无数次最后
: 干脆断掉了直接在网上聊:) 题目是实现int power(int x, int y), 先写最简单的那种, 然后
: 写个better running time, 然后写个只用constant memory的. 最后一个constant

t****0
发帖数: 235
34
cong
g*********s
发帖数: 1782
35
hi, why ur site name is "ihas1337code". does that mean "i has 1337 code"?
why not "i have"?

yield
in
non-
string

【在 i**********e 的大作中提到】
: "Then the minimum possible of numbers of the next next group must also yield
: a total of k groups of numbers, which the length is also 2k, which is in
: non-increasing order in length."
: The proof is for the case which yields the "minimum" possible of number
: where the minimum length = 2*k can produce sequence length's in non-
: increasing order. It doesn't mean the next sequence's length must be non-
: increasing.
: I might still be wrong though, correct me if I'm wrong.
: Can LZ please share how to answer: "Proof whether there is an input string
: that can produce a sequence that's strictly non-increasing in length.",

g*********s
发帖数: 1782
36
if strictly decreasing, then finally it would hit to a single digit and
then start to increasing.
so u sure the interviewer asks "strictly decreasing"?

string
strictly
还是

【在 w*****x 的大作中提到】
: 我感觉是我把题目记错了, interviewer问的应该是proof whether there is a string
: that can produce a sequence strictly decreasing in length. 不是non-
: increasing.
: 如果是non-increasing我也觉得除了"22"之外就没有了. 当时没有严格的证明strictly
: decreasing不存在, 只是举了两个例子:
: 比如"111", 后面是"31", 然后是"1311". "31"就是最小的length.
: "1111"(之前是"一百一十一个1", 之前是更多的1), 之后是"41", 然后"1411". 长度还是
: 在"41"是达到最小, 然后开始增加.
: 所以就算从无穷多的1开始, 最后会达到一个"xxxx1"的情况, 这时候长度最短, 然后就
: 开始增加

Z*****Z
发帖数: 723
37
you raised two good points

【在 g*********s 的大作中提到】
: if strictly decreasing, then finally it would hit to a single digit and
: then start to increasing.
: so u sure the interviewer asks "strictly decreasing"?
:
: string
: strictly
: 还是

i**********e
发帖数: 1145
38
谢谢,不敢当.
还有要谢谢你分享的面试题
以后要招人请别忘了 referral 我哦... (开玩笑的 嘻嘻) :)
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

string
strictly
还是

【在 w*****x 的大作中提到】
: 我感觉是我把题目记错了, interviewer问的应该是proof whether there is a string
: that can produce a sequence strictly decreasing in length. 不是non-
: increasing.
: 如果是non-increasing我也觉得除了"22"之外就没有了. 当时没有严格的证明strictly
: decreasing不存在, 只是举了两个例子:
: 比如"111", 后面是"31", 然后是"1311". "31"就是最小的length.
: "1111"(之前是"一百一十一个1", 之前是更多的1), 之后是"41", 然后"1411". 长度还是
: 在"41"是达到最小, 然后开始增加.
: 所以就算从无穷多的1开始, 最后会达到一个"xxxx1"的情况, 这时候长度最短, 然后就
: 开始增加

i**********e
发帖数: 1145
39
@grandjmitbbs:
I decided to name my site as "i has 1337 code" because of the lolcats
internet culture hehe. See here:
http://en.wikipedia.org/wiki/Lol_cats
@grandjmitbbs & ZhangBZ:
It seemed obvious (based on our intuitions) that it would never have such
inputs which produce sequences decreasing in length, but maybe the
interviewer wants LZ to prove it (remember, it's easy to follow your
intuition, but not necessarily easy to construct a correct proof).
一些常见面试题的答案与总结 -
http://www.ihas1337code.com
g*****y
发帖数: 215
40
cong
相关主题
Amazon, too.从王垠的代码看似乎其没在正规公司呆过 (转载)
salary increase within local job change问一道google的题
Amazon interview question.(4)现在面试可以用Java8吗?
进入JobHunting版参与讨论
j*****u
发帖数: 1133
41
明白了,类似这样:
// assume x > 0, y > 0
int Power(int x, int y)
{
int pow = 1;
while (y > 0)
{
if ((y & 1) != 0) pow *= x;
x *= x;
y >>= 1;
}
return pow;
}

【在 w*****x 的大作中提到】
: 我感觉是我把题目记错了, interviewer问的应该是proof whether there is a string
: that can produce a sequence strictly decreasing in length. 不是non-
: increasing.
: 如果是non-increasing我也觉得除了"22"之外就没有了. 当时没有严格的证明strictly
: decreasing不存在, 只是举了两个例子:
: 比如"111", 后面是"31", 然后是"1311". "31"就是最小的length.
: "1111"(之前是"一百一十一个1", 之前是更多的1), 之后是"41", 然后"1411". 长度还是
: 在"41"是达到最小, 然后开始增加.
: 所以就算从无穷多的1开始, 最后会达到一个"xxxx1"的情况, 这时候长度最短, 然后就
: 开始增加

n*******s
发帖数: 482
42
mark
1 (共1页)
进入JobHunting版参与讨论
相关主题
请教关于 F的电面salary increase within local job change
Google面试题Amazon interview question.(4)
[合集] 没人回复,直接上板上讨论吧。如果违反版规希望斑竹删掉就是从王垠的代码看似乎其没在正规公司呆过 (转载)
H1B拿到后,如果被公司layoff后可以到其它公司工作么问一道google的题
这道题怎么做?现在面试可以用Java8吗?
问个电面题facebook 一面
一道google 题,谁给翻译一下意思,多谢。facebook的buffet puzzle
Amazon, too.求facebook puzzle的测试文件
相关话题的讨论汇总
话题: string话题: int话题: length话题: increasing话题: next