Take a one dimensional array as the multiplication of both the dimensions
of the two dimensional array and copy the two dimensional array elements in
the one dimensional array.
After that use an efficient sorting (e.g. quick sort) on this one
dimensional array

Regards,
- Amit
-------------------
Sent from Nexus 4
On Jan 8, 2013 11:30 PM, "Ravi Ranjan" <ravi.cool2...@gmail.com> wrote:

> You have a two dimensional array of size m*n. The
> elements in the rows are sorted and every row has
> unique elements means( in a row no two elements are same) but
> the elements can repeat across the rows.
> For example:
> you have following 2-D array:
> 2 5 7 9 14 16
> 3 6 8 10 15 21
> 4 7 9 15 22 35
> 7 8 9 22 40 58
> You are supposed to write an efficient function which
> will take upper 2-D array as input and will return a
> one-dimensional array with following properties:
> a) the 1-D array must contain all the elements of above
> 2-D array.
> b) the 1-D array should not have any repeated elements.
> c) all the elements should be in sorted order.
> For example:
> for the above 2-D array, the output should be:
> A [ ] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 21, 22, 35,
> 40, 58 }
>
> --
>
>
>

-- 


Reply via email to