推荐:数据科学课程和书籍清单以及培训讲座


一亩三分地论坛

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

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

Twitter 实习电面

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

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

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

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

x
Twitter
上来双方自我介绍然后tell me about your internship? what do you want to do in Twitter/. 然后直接出了一道distinct subsequence的题目,leetcode原题, 我出现了一些小bug:  

// This is the text editor interface. . more info on 1point3acres.com

// Anything you type or change here will be seen by the other person in real time.

Input: String s, String t. from: 1point3acres.com/bbs
Output: Number of subsequences of s that equal t

example:
s: "aaba"
__
_ _. from: 1point3acres.com/bbs
_ _
t: "aa"
. 鍥磋鎴戜滑@1point 3 acresoutput: 3

s: "aaba".鐣欏璁哄潧-涓浜-涓夊垎鍦
_ _. 鍥磋鎴戜滑@1point 3 acres
__
__ DOES NOT COUNT (this is "ba", not "ab")
t: "ab"
output: 2

public int countSub(String s, String t){
char[] S = s.toCharArray();
char[] T = t.toCharArray();
. more info on 1point3acres.com
int m = T.length, n = S.length;
int[][] count = new [m+1][n+1];

if(n < m)
return 0;-google 1point3acres

for(int j = 1; j <= n; j++)
count[0][j] = 1;
. Waral 鍗氬鏈夋洿澶氭枃绔,
//keep populate the cache
for(int i = 1; i <= m; i++)
for(int j = 1; j <= n; j++){
//two case
if(T[i-1] == S[j-1])                                    //BUG: index should be i-1 and j-1, not i, j
count[j] = count[i-1][j-1] + count[j-1]; //BUG: 忘记加后面的那一项了
else
count[j] = count[j-1]; //.鏈枃鍘熷垱鑷1point3acres璁哄潧
}-google 1point3acres
. more info on 1point3acres.com
return count[m][n];
}
鏉ユ簮涓浜.涓夊垎鍦拌鍧.

评分

1

查看全部评分

readman 发表于 2015-5-23 12:12:53 | 显示全部楼层
楼主这是什么时候面的?
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2017-8-20 16:26

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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