近期论坛无法登录的解决方案


一亩三分地论坛

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

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

Google电面题两道

[复制链接] |试试Instant~ |关注本帖
boy27910230 发表于 2014-11-23 00:54:50 | 显示全部楼层 |阅读模式

2014(10-12月) 码农类 硕士 全职@Google - 内推 - 技术电面 |Pass

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

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

x
Google Doc上直接扒下来的,两道题都不难但是第一题从没遇到过经过提示后才想出来的,第二题别人发过面经

—--

Do a quick approximation of the number of bytes needed to store a timestamp value in microseconds

that will span until the beginning of 2020?

Quick approximation: --> come up with an answer without doing complicated operations (i.e. no

calculator, just back of the envelope computations).

1s = 1000*1000ms

1min = 60s
. Waral 鍗氬鏈夋洿澶氭枃绔,
1h = 60 m
.鐣欏璁哄潧-涓浜-涓夊垎鍦
1d 24 h

1y = 365d

1 timestamp = 6* 365*24*60*60*1000*1000

10^14

2^3.X

2^14*3=2^42. 1point 3acres 璁哄潧

42/8 = 5.

6bytes. 鍥磋鎴戜滑@1point 3 acres
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
————--
. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
Given a string of 0s, 1s, and ?s (wildcards), generate all 0-1 strings that match an input pattern.

For example:

0?1 --> 001, 011

1?00?101 -> 10000101, 10001101, 11000101, 11001101

You can generate the strings in any order that suits you.

public List<String> wildcard(String str){

if(str == null || str.length() == 0){
throw new IllegalArgumentException();
}
. 涓浜-涓夊垎-鍦帮紝鐙鍙戝竷
List<String> result = new ArrayList<String>();

helper(str, result );

return result;

}
. 1point3acres.com/bbs
public void helper(String str, List<String> result){

if(!str.contains(“?”)){
result.add(str);
return;. 鍥磋鎴戜滑@1point 3 acres
}

int index = 0. 1point3acres.com/bbs

for(; index < str.length(); index ++){
if(str.charAt(index) == ‘?’){
break;
}. 1point3acres.com/bbs

}

char[] strCharArray = str.toCharArray();
. visit 1point3acres.com for more.
strCharArray[index] = ‘0’;

helper(new String(strCharArray), result);. from: 1point3acres.com/bbs

strCharArray[index] = ‘1’;.鐣欏璁哄潧-涓浜-涓夊垎鍦

. 鍥磋鎴戜滑@1point 3 acreshelper(new String(strCharArray), result);-google 1point3acres

}
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
averillzheng 发表于 2014-11-23 01:28:56 | 显示全部楼层
关注一亩三分地公众号:
Warald_一亩三分地
1s = 1000 * 1000ms,
是不是有点笔误,还是我记错了?
回复 支持 反对

使用道具 举报

 楼主| boy27910230 发表于 2014-11-23 01:33:20 来自手机 | 显示全部楼层
关注一亩三分地微博:
Warald
ms是microsecond, 不是millisecond
回复 支持 反对

使用道具 举报

averillzheng 发表于 2014-11-23 01:35:40 | 显示全部楼层
boy27910230 发表于 2014-11-23 01:33
ms是microsecond, 不是millisecond

喔,我没有看清题目。. Waral 鍗氬鏈夋洿澶氭枃绔,

面壁ing
回复 支持 反对

使用道具 举报

averillzheng 发表于 2014-11-23 01:36:29 | 显示全部楼层
boy27910230 发表于 2014-11-23 01:33
ms是microsecond, 不是millisecond
. 鍥磋鎴戜滑@1point 3 acres
恭喜恭喜,onsite马上就要来了
回复 支持 反对

使用道具 举报

本版积分规则

关闭

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

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

custom counter

GMT+8, 2017-6-22 22:35

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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