面试形式:共享屏幕,自己的IDE写代码:
第一题:atoi
这个是一个经典题目,但是具体实现取决于和面试管的沟通,以及面试管的专业程度,一般按照leetcode标准写法即可。
得分点:
1. 空字符串的处理(取绝于题目要求)
2. 不合法字符串的处理(取绝于题目要求)
3. 空格的处理 (1分)
4. 符号的处理 (2分)
5. 符号的处理 (2分)
6. 主要的逻辑函数 (5分)
class Solution {
public int myAtoi(String str) {
int n = str.length(), i = 0, sign = 1;
while(i
if(i
sign = -1;
i++;
}
else if(i
long res = 0;
while(i='0'&&str.charAt(i)<='9'){
res = res*10 + str.charAt(i) - '0';
if(sign*res>Integer.MAX_VALUE) return Integer.MAX_VALUE;
if(sign*res
i++;
}
res = sign * res;
return (int) res;
}
}
合并k个排序数组(建议使用分治法,因为这个好写,只要会两个就会K个)