注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
第一轮 黑妹 给一组replacements<beginIndex,replaceString,replacedString> 和原字符串str,先判断原字符串str从beginIndex开始的substring为replacedString,如果存在,把它replace成replaceString。LC吧吧散。想问问下面这样的写法时间复杂度多大,不包括sorting?- public String findReplaceString(String S, int[] indexes, String[] sources, String[] targets) {
- List<int[]> indexList = new LinkedList<>();
- for (int i = 0; i < indexes.length; i++) {
- indexList.add(new int[]{indexes[i], i});
- }
- Collections.sort(indexList, (a, b) -> a[0] - b[0]);
- StringBuilder sb = new StringBuilder();
- int last = 0;
- for (int[] index : indexList) {
- int strIndex = index[0];
- int sourceIndex = index[1];
- if (S.substring(strIndex).indexOf(sources[sourceIndex]) == 0) {
- sb.append(S.substring(last, strIndex));
- sb.append(targets[sourceIndex]);
- last = strIndex + sources[sourceIndex].length();
- }
- }
- if (last != S.length()) {
- sb.append(S.substring(last));
- }
- return sb.toString();
- }
复制代码 第二轮 有口音的白人 给一个dict,包含很多string,找出类似于这样的abc-&lc那道题吗
后面两轮都问了最近的technical challenge,有一两轮都问了会用什么cases去做test,会怎么test。祈祷下周补的bq轮,攒人品,求米。
补充内容 (2022-04-29 08:14 +8:00):
第一轮是吧散散 打错 |