Huawei OD machine test question array merge, JAVA & Python & C & C++ & GO & JavaScript
topic
Now that there are multiple sets of integer arrays, they need to be merged into a new array.
Merge rules, take out the fixed-length content from each array in order and merge them into a new array, and
delete the finished content.
If the line is less than the fixed length or is already empty,
directly take out the remaining content and put it in In the new array, continue to the next line.
For example 1
, to obtain the length 3
, first traverse the first row to obtain 2,5,6
;
then traverse the second row to obtain 1,7,4
; then loop back to the first row to
obtain 7,9,5
; then traverse the second row to obtain 3,4
;
then return to the first row to obtain 7
, stitched together into the final result.
enter
The first line is the fixed length of each read; 0<长度<10
the
second line is the number of integer arrays 0<数目<1000
, and
the 3~n
line is the arrays to be merged. Different arrays are separated by carriage returns and newlines, and
the arrays are separated by commas. Maximum 100
of elements
output
Output a new array, separated by commas
example one
enter
3
2
2,5,6,7,9,5,7
1,7,4,3,4
<