boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 刚刚FB电面试完
相关主题
请问LC上一道题:Validate BST
分享Imo电面题
问个google老题的最佳解法
Interleave Strings那个题目有O(n)时间 O(1)空间算法么?
String list如何排序
FB面试题一道 求解
请教一个phone interview 问题
最失败的一次onsite - bloomberg
关于trie和binary search tree的疑问。
这个check whether a binary tree is a BST or not
相关话题的讨论汇总
话题: int话题: cur话题: string话题: positive话题: curnum
进入JobHunting版参与讨论
1 (共1页)
I*******g
发帖数: 7600
1
还可以。
r*******e
发帖数: 971
2
这样不放面经也太不厚道了。
l***4
发帖数: 1788
3
上面经吧哥们

【在 I*******g 的大作中提到】
: 还可以。
w****a
发帖数: 710
4
来来 大家猜题买注了
我猜个三题
1. decode ways
2. sort colors
3. BT/BST iterator
c******w
发帖数: 1108
5
我猜一道search in rotated sorted array
I*******g
发帖数: 7600
6
两道题
1)pre-fix String search
我写了一个TRIE class
2) String evaluation: eg. Given 3 +2x +5y -(3 +5x) = 8 -7y +2x and X value
, return Y value

【在 I*******g 的大作中提到】
: 还可以。
w****a
发帖数: 710
7
猜错了。
赞分享,按照FB最近的趋势,楼主是offer的节奏。bless!
k******e
发帖数: 145
8
求问第二题思路。。

value

【在 I*******g 的大作中提到】
: 两道题
: 1)pre-fix String search
: 我写了一个TRIE class
: 2) String evaluation: eg. Given 3 +2x +5y -(3 +5x) = 8 -7y +2x and X value
: , return Y value

h****t
发帖数: 69
9
1) Tokenize string
2) Parse tokens using a stack
3) Use math to evaluate y

【在 k******e 的大作中提到】
: 求问第二题思路。。
:
: value

s***c
发帖数: 639
10
这两道题45分钟内全写对太反人类了吧。第二题还要写个tokenizer什么的,时间够么
加上板上其他人报的FB面经,FB的电面难度跨度太大了,难以捉摸

value

【在 I*******g 的大作中提到】
: 两道题
: 1)pre-fix String search
: 我写了一个TRIE class
: 2) String evaluation: eg. Given 3 +2x +5y -(3 +5x) = 8 -7y +2x and X value
: , return Y value

相关主题
Interleave Strings那个题目有O(n)时间 O(1)空间算法么?
String list如何排序
FB面试题一道 求解
请教一个phone interview 问题
进入JobHunting版参与讨论
c******y
发帖数: 6
11
第二题太变态了
w****m
发帖数: 235
12
什么叫tokenize string
x*******6
发帖数: 262
13
贡献一个code,由于没有乘除,只需要记录括号内是否要根据加减改变数字的符号,不
需要使用reverse polish notation解法。
public static int eval(String s, int x) {
String[] exp = s.split("=");
int[] left = helper(exp[0],x);
int[] right = helper(exp[1],x);
return (left[0] - right[0])/(right[1]-right[0]);
}
private static int[] helper(String s, int x) {
boolean positive = true;
Stack re = new Stack();
re.push(false);
int num = 0;
int y = 0;
for (int i = 0; i < s.length(); i++) {
char cur = s.charAt(i);
if (cur >= '0' && cur <= '9') {
boolean localPositive = re.peek()?!positive:positive;
int curNum = localPositive ? cur - '0' : '0' - cur;
if (i < s.length() - 1) {
if (s.charAt(i + 1) == 'x') {
curNum *= x;
i++;
} else if (s.charAt(i + 1) == 'y') {
y += curNum;
i++;
continue;
}
}
num += curNum;
} else if (cur == '+') {
positive = true;
} else if (cur == '-') {
positive = false;
} else if (cur == '(') {
re.push(!(positive^re.peek()));
positive = true;
} else if(cur == ')'){
re.pop();
}
}
int[] res = new int[2];
res[0] = num;
res[1] = y;
return res;
}
t*******y
发帖数: 22
14
没说是single number 吧?

【在 x*******6 的大作中提到】
: 贡献一个code,由于没有乘除,只需要记录括号内是否要根据加减改变数字的符号,不
: 需要使用reverse polish notation解法。
: public static int eval(String s, int x) {
: String[] exp = s.split("=");
: int[] left = helper(exp[0],x);
: int[] right = helper(exp[1],x);
: return (left[0] - right[0])/(right[1]-right[0]);
: }
: private static int[] helper(String s, int x) {
: boolean positive = true;

t*******e
发帖数: 274
15

value
第一题的题目内容能描述下么?

【在 I*******g 的大作中提到】
: 两道题
: 1)pre-fix String search
: 我写了一个TRIE class
: 2) String evaluation: eg. Given 3 +2x +5y -(3 +5x) = 8 -7y +2x and X value
: , return Y value

x*******6
发帖数: 262
16

感觉考点应该是接触符号时判断正负号。tokenization没什么好考的

【在 t*******y 的大作中提到】
: 没说是single number 吧?
l**o
发帖数: 25
17
第二题leetcode上有吗
1 (共1页)
进入JobHunting版参与讨论
相关主题
这个check whether a binary tree is a BST or not
一道算法题
"Hacking a G Interview"怎么有这样低级错?
Bloomberg面经(onsite)
最近面试碰到的题目
也被A电了一下
[难题求助] leetcode wordsearch
现在出发去F onsite
G/F面经
F M面经
相关话题的讨论汇总
话题: int话题: cur话题: string话题: positive话题: curnum