亲!马上注册或者登录会查看更多内容!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 Sophia 于 4-4-2016 02:38 PM 编辑 + G) v: Q1 J j" }) _$ Q( g( y- A
# ^) S; i" l/ V0 f* L
美国人,名字叫Tim,稍微查了一下他的背景:一个数据博士,专于音频开发,还自己写了书,曾经在google工作过一年。人很nice,题目是cc150里的,
1 O5 K; Z8 M) I( Mgaven a array and target , return the two index which the sum of two is the target number! W# |" X+ M+ g# p [: m. z1 L
so easy,
1 \' w( d/ R9 ~) w& X, c5 ~ public int[] twoSum(int[] numbers, int target) { HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); int[] result = new int[2]; # P( ~; O6 v) J1 C) o6 P* N# i
for (int i = 0; i < numbers.length; i++) { if (map.containsKey(numbers【i】)) { int index = map.get(numbers【i】); result[0] = index ; result[1] = i; break; } else { map.put(target - numbers【i】, i); } } return result; }6 |; B8 C& }, ?; N7 p; |/ M7 P
! L3 H2 e6 \6 v# e' } Q
t7 i6 y8 S$ ~1 u4 }% c+ u然后问了这个算法的complexity,
" m U% H, E( k5 ?+ p9 Z/ m时间还有很多,聊了我的简历和项目,最后给了我提问的机会,和看他的名字和apple的CEO很像,就SS地问是不是他本人,然后就SB了。当天下午就收到了拒绝电邮了,所以大家千万别像我一样SS地问一些弱智的问题。
, b4 m# f2 \4 I$ C7 X! e6 }$ N |