I am trying to figure out how to combine an 2Dint array containing multiple rows of uneven size into one sorted 1D int array in Java.
For example, if my 2D array is similar to [[2, 8], [16, 35], [1, 4], [5, 7, 19]], it will merge into a sorted 1D array [1, 2, 4, 5, 7, 8, 16, 19, 35].
The header for my function looks like this: with a semi-split 2D array and a 1D array that are sorted, are the arguments:
public void mergeTo1D(int[][] sorted, int[] origArray) {
}
I saw some solutions here that use a mini-heap, but I have no idea how to implement or work with it, as I am just starting to learn data structures.
source
share