class NcFileStitcher {

    static int[][] determineDestinationOffsets(int[] rowOffsets, int[] numberOfRows,
                                               int[] sectionSizes, int[][] sourceOffsets) {
        int[][] destinationOffsets = new int[sectionSizes.length][];
        int allSectionsSize = 0;
        for (int sectionSize : sectionSizes) {
            allSectionsSize += sectionSize;
        }
        for (int i = 0; i < sectionSizes.length; i++) {
            final int fileOffset = rowOffsets[i] * (sectionSizes[i] / numberOfRows[i]);
            destinationOffsets[i] = new int[sourceOffsets[i].length];
            for (int j = 0; j < sourceOffsets[i].length; j++) {
                destinationOffsets[i][j] = fileOffset + j * allSectionsSize;
            }
        }
        return destinationOffsets;
    }

}