How to return arrays with the biggest elements in C#?
Posted
by
theateist
on Stack Overflow
See other posts from Stack Overflow
or by theateist
Published on 2012-10-28T13:48:27Z
Indexed on
2012/10/28
23:02 UTC
Read the original article
Hit count: 255
I have multiple int arrays:
1) [1 , 202,4 ,55]
2) [40, 7]
3) [2 , 48 ,5]
4) [40, 8 ,90]
I need to get the array that has the biggest numbers in all positions. In my case that would be array #4. Explanation:
- arrays #2, #4 have the biggest number in 1st position, so after the first iteration these 2 arrays will be returned ([40, 7] and [40, 8 ,90])
- now after comparing 2nd position of the returned array from previous iteration we will get array #4 because 8 > 7
- and so on...
Can you suggest an efficient algorithm for this? Doing with Linq will be preferable.
UPDATE
There is no limitation for the length, but as soon as some number in any position is greater, so this array is the biggest.
© Stack Overflow or respective owner