Method takes a two-dimensional array and converts it into a regular one-dimensional array. The new one-dimensional array
Fantastic news! We've Found the answer you've been seeking!
Question:
Method takes a two-dimensional array and converts it into a regular one-dimensional array. The new one-dimensional array is returned from the method.
If the original array is empty, an empty array must be returned.
The assumption is that all rows of the original array are of the same length.
Examples:
int[][] a= {{1, 2, 3},
{4, 5, 6}, => {1, 2, 3, 4, 5, 6, 7, 8, 9}
{7, 8, 9}};
int[][] a= {{1, 2, 3},
{4, 5, 6}} => {1, 2, 3, 4, 5, 6}
int[][] a= { } => { }
Efficiency requirements
- Do not use any additional data structures, ArrayLists, collections etc. for temporary storage. Only one array must be allocated - the one that will be returned from the method.
- You must write code that passes only once through all the elements of the original array.
Add Doc comments before the method header.
Related Book For
Analysis Synthesis And Design Of Chemical Processes
ISBN: 9780134177403
5th Edition
Authors: Richard Turton, Joseph Shaeiwitz, Debangsu Bhattacharyya, Wallace Whiting
Posted Date: