1 Line C# Linq solution

  • 0

    Not the fastest, but easy to read for people familiar with Linq.

    public class Solution {
        public int MajorityElement(int[] nums) {
            return nums.GroupBy(x => x).OrderByDescending(gp => gp.Count()).First().Key;

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.