2024年华为OD机试真题-矩阵扩散-Java-OD统一考试(E卷)

时间:2024-11-07 18:43:51
华为OD机试真题-数组拼接-2024年OD统一考试(E卷)

cclczx: int[] result = new int[count]; count = 0; int[] lineIndex = new int[num]; int completedArrCount = 0; for (int i = 0; completedArrCount < num; i = (i + 1) % lineIndex.length) { Integer[] arr = list.get(i); if (lineIndex[i] == arr.length) { completedArrCount++; continue; } int currentIndex = lineIndex[i]; for (int j = currentIndex; j < currentIndex + len && j < arr.length; j++) { result[count] = arr[j]; count++; lineIndex[i]++; } }