You are viewing a single comment's thread. Return to all comments →
int result = ar.Where(i => i == ar.Max()).Count();
That's O(n^2) since you're finding the max value on each iteration of the where statement. The best solution would be to use a single for/foreach loop, but jeffmagill's solution (looping through the list twice) is still much more efficient than this.
I don't think you deserver a downvote, its solution i came up with the returned failed tests (tests timed out) for me.
I wish it was explained where other than comments why this wasn't a valid result.