May 2009 - May 2017 论坛八周年-你的足迹,我的骄傲


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 1116|回复: 3
收起左侧

Facebook电面

[复制链接] |试试Instant~ |关注本帖
106 发表于 2015-5-23 12:02:32 | 显示全部楼层 |阅读模式

2015(1-3月) 码农类 硕士 全职@Facebook - 内推 - 技术电面 |Passfresh grad应届毕业生

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
前面十分钟完全没有问我的简历, 问一些比如为啥想读一个master in computer science, facebook有哪些方面可以提高啊, 等等, 感觉问这些只是为了把时间拖到10分钟, coding 30分钟, 租后问问题5分钟


import java.io.*;
import java.util.*;

/*
* To execute Java, please define "static void main" on a class
* named Solution.
*. 鍥磋鎴戜滑@1point 3 acres
* If you need more classes, simply define them inline.
*/

class Solution { 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
public static void main(String[] args) {

// a = [9, 0, 5, 12, 1, 6]
// low = 2
// high = 8. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
// | |


// step 2 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
// a = [0, 1, 5, 6, 12, 9]. 1point3acres.com/bbs
// l k r
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
// idea 1: left/right pointers
// left:
// right:
// -> swap to correct section
// time: linear: O(n)
// space: constant: 2 pointers
public void sort(int[] A, int low, int high){
//assume the input is valid
int i = -1, j = A.length;. more info on 1point3acres.com
int k = 0;. 1point3acres.com/bbs
while(k < j){ 鏉ユ簮涓浜.涓夊垎鍦拌鍧.
if(A[k] <= low)
swap(A, ++i, k);
else if(A[k] >= high)
swap(A, k, --j);
else
k++;
}
}

// returns true -> if all chars are unique
// returns false --> if there are any duplicate
// 'abc' -> true
// 'abbc' -> false
// idea 1:
// hashset<char>
// idea 2: sort first, then no extra space
public bool isUnique(char[] s) {
Set<char> h = new HashSet<char>();
// space = constant
// * 128 log(128) || log(256)
int set = 0; // 00000


Actually, I think we need at least 128 bit to solve this problem because assuming
we have all the 128 different char in the input, then we need to store the infomation about if a specific char we have visited before.

for each char in S. more info on 1point3acres.com
check if this char has existed based on the info in set
if does
reutrn false;
. from: 1point3acres.com/bbs
store the info about the existence of this char in set

end

return true;
.鏈枃鍘熷垱鑷1point3acres璁哄潧

}



. visit 1point3acres.com for more.




.鐣欏璁哄潧-涓浜-涓夊垎鍦






. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴

. 1point3acres.com/bbs
. From 1point 3acres bbs

. visit 1point3acres.com for more.

. visit 1point3acres.com for more.

.鐣欏璁哄潧-涓浜-涓夊垎鍦

}
}-google 1point3acres


. Waral 鍗氬鏈夋洿澶氭枃绔,


鏉ユ簮涓浜.涓夊垎鍦拌鍧.
lx051068 发表于 2015-5-23 12:44:54 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
楼主好像没有说题目是什么呢。。
回复 支持 反对

使用道具 举报

yuxrose 发表于 2015-5-24 05:01:15 | 显示全部楼层
关注一亩三分地微博:
Warald
第一题是什么意思啊。。。。。
回复 支持 反对

使用道具 举报

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2017-5-30 03:05

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表