Is there a way to use Linq in C# to find the majority of elements in an array? To make it a bit more complicated, if there is no majority, it should take the first element.
So for example with the array ["A", "B", "B"]
, the statement should evaluate to "B"
.
And, with the array ["A", "B", "C"]
, the statement should evaluate to "A"
.
I'm sure there are a 100 other ways to do this, but curious if there is a Linq solution.