算法与数据结构单选难度 3真题改编 · 2023
2453. 给定2个串: $c='newcoder',d='new \quad coder'$ ,函数 Concat(s,t) 返回串 s 和串 t 连接的结果;函数 SubStr(s,i,j) 返回串 s 的第 i 个位置开始的 j 个字符;函数 DelStr(s,i,j) 表示删除串 s 中从第 i 个位置开始的 j 个字符,则执行Concat(DelStr(d,4,1),SubStr(c,1,3)) 之后的结果是()
练习本题 ›
操作系统单选难度 3真题改编 · 2024
2455. 假设操作系统中有5个作业,它们的到达时刻分别是0,2,4,6,8,运行时间分别是2,3,1,4,2,系统在t=2时开始作业调度,如果采用优先级调度算法,其中作业的优先级按到达时刻从小到大依次递增,那么在t=2时,选中的作业是()。
练习本题 ›
编程语言单选难度 3真题改编 · 2024
2486. 实现一个函数,返回整数数组中所有唯一组合。假设数组中元素无重复。
import java.util.*;
public class UniqueCombinations {
public static List<List<Integer>> combine(int[] nums) {
List<List<Integer>> result = new ArrayList<>();
backtrack(result, new ArrayList<>(), nums, 0);
return result;
}
private static void backtrack(List<List<Integer>> result, List<Integer> tempList,
int[] nums, int start) {
result.add(new ArrayList<>(tempList));
for (int i = start; i < nums.length; i++) {
____ // 填空
backtrack(result, tempList, nums, i + 1);
tempList.remove(tempList.size() - 1);
}
}
public static void main(String[] args) {
int[] nums = {1, 2, 3};
List<List<Integer>> combinations = combine(nums);
for (List<Integer> combination : combinations) {
System.out.println(combination);
}
}
}
填空内容是:
练习本题 ›