快手测开一面(果然还是理解不了老铁基因)
一面,等了8分钟,面试官姗姗来迟
问了几个实习经历的问题
四个八股
- mysql的索引数据结构
- 索引什么时候一般会失效
- Java里接口和抽象类区别和使用场景
- hashtable和hashmap的区别(我没用过hashtable,八股也没看过,于是我仔细说了下hashmap,但从这个时候开始,面试官似乎就决定不要我了
直接代码题,算法题都算不上,就是特定的文件内容解析罢了。
import java.util.*; /** * 现有一个记录函数信息的json文件testmethods.json,如下所示:记录了函数的开始和结束位置: * * {"testmethod1":[12,34],"testlogin":[45,60],"searchgood":[70,100] ...} * * 在我们测试用例的时候,会得到一个覆盖行的列表,如下所示:coved_lines=[11,13,44,50,58,80] * * 根据testmethods.json文件中记录的函数信息,结合覆盖率返回的行号列表,查找出测试覆盖的函数列表。 */ public class Main { public static List<String> getCoverLineMethodName(String testmethods, int[] cover_lines) { String s1 = testmethods.substring(1, testmethods.length() - 1); String[] methodStr = s1.substring(1).split(",\""); Map<String, ArrayList<Integer>> linesMap = new HashMap<>(); for (String s : methodStr) { String[] s2 = s.split(":"); String tempKey = ""; for (String s3 : s2) { if (s3.contains("\"")) { String newKey = s3.substring(0, s3.length() - 1); linesMap.put(newKey, new ArrayList<>()); tempKey = newKey; } else if (s3.contains("[")){ String[] s4 = s3.substring(1, s3.length() - 1).split(","); for (String lineStr : s4) { linesMap.get(tempKey).add(Integer.parseInt(lineStr)); } } } } ArrayList<String> res = new ArrayList<>(); for (int cover_line : cover_lines) { for (Map.Entry<String, ArrayList<Integer>> entry : linesMap.entrySet()) { if (entry.getValue().get(0) <= cover_line && cover_line <= entry.getValue().get(1)) { if (res.contains(entry.getKey())) break; res.add(entry.getKey()); } } } return res; } public static void main(String[] args) { String testmethods = "{\"testmethod1\":[12,34],\"testlogin\":[45,60],\"searchgood\":[70,100]}"; int[] cover_lines = {11,13,44,50,58,80}; List<String> coverLineMethodName = getCoverLineMethodName(testmethods,cover_lines); System.out.println(coverLineMethodName); } }
面试官手动测了几下,然后说,好了,今天就到这里了,你有什么想问的吗?
我直接????????