How to return arrays with the biggest elements in C#?
- by theateist
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.