面试描述
自我介绍. 自我介绍之前网络十分不好, 垃圾电脑. 劝大家面试前一定检查好网络状况. 否则很影响面试官心情.
自我介绍完了之后问
看你的专业是大数据分析, 为什么不去做模型做算法
?说一下大数据的各个组件和功能吧
说一下mapreduce或spark分布式计算的原理
写个题吧, three sum, 不能重复, 升序排列. 这里一定要记住去掉重复的组合
1
2
3if(i > 0 && num[i] == num[i-1]){
continue;
}和
1
2
3
4
5while(left > i + 1 && num[left] == num[left - 1]){
++left;
}
//面试的时候这个条件写错了, 怎么运行都不正确, 后来面试官急着开会, 让我改完发他邮箱, 才发现是这里的问题.
应该为 while(left > i + 1 && left < num.length - 1 && num[left] == num[left - 1])和
1
2
3
4while(right < num.length - 1 && num[right] == num[right + 1]){
--right;
}
应该为 while(right < num.length - 1 && right > i + 1 && num[right] == num[right + 1])1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49import java.util.*;
public class Solution {
public ArrayList<ArrayList<Integer>> threeSum(int[] num) {
if(num == null || num.length < 3){
return new ArrayList<ArrayList<Integer>>();
}
Arrays.sort(num);
ArrayList<ArrayList<Integer>> ans = new ArrayList<>();
for(int i = 0; i < num.length - 2; ++i){
if(i > 0 && num[i] == num[i-1]){
continue;
}
int target = -num[i];
int left = i + 1;
int right = num.length - 1;
while(left < right){
while(left > i + 1 && num[left] == num[left - 1]){
++left;
}
while(right < num.length - 1 && num[right] == num[right + 1]){
--right;
}
if(left >= right){
break;
}
int tmp = num[left] + num[right];
if(tmp == target){
ArrayList<Integer> curr = new ArrayList<>();
curr.add(num[i]);
curr.add(num[left]);
curr.add(num[right]);
System.out.println(curr);
ans.add(curr);
++left;
--right;
}
else if(tmp > target){
--right;
}
else{
++left;
}
}
}
return ans;
}
}
总体上面试难度不大, 编程题也不难, 刚看到题的时候立马就想出来思路了. 但是在去重上耽误了太多的时间, 最后没有运行出来. 刚开始面试的时候网络也没调试好, 估计给面试官的体验也不太好, 希望能过吧.