List of most occurrences of element

cAMPy

I have a list let's say {1,1,2,2,3,3,3,4,4,4}. I want to find a List of the elements that occur the most often (it has to be a list as there can be a situation like here that 3 and 4 occur most and I need to get that information. How can I achieve this using LINQ?

Salah Akbari

By Grouping:

var grp = list.GroupBy(i => i).ToList();
int max = grp.Max(c => c.Count());
var most = grp.Where(d => d.Count() == max)
              .Select(c => c.Key).ToList();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Find the element with most occurrences in a list in Racket

From Dev

When a draw occurs when tracking most occurrences in a list how to find element with highest index?

From Dev

Finding the most frequent occurrences of pairs in a list of lists

From Dev

Ordering a list by most occurrences of lowest number

From Dev

Python: Counting occurrences of List element within List

From Java

How to find all occurrences of an element in a list

From Dev

Recursive Python function to count occurrences of an element in a list

From Dev

I want to count the occurrences of an element in a list

From Dev

How to count occurrences of specific element for arrays in a list?

From Dev

Count and remove the successive occurrences of the first element in a list

From Dev

Deleting repetitive occurrences of same element in list

From Dev

How to count occurrences of specific element for arrays in a list?

From Dev

Abstract List Functions in Racket/Scheme - Num of element occurrences in list

From Dev

Java-get most common element in a list

From Dev

C#: Get Most Occurring Element in a List?

From Dev

Haskell - count most repeated element in a list with interact

From Dev

In-place replacement of all occurrences of an element in a list in python

From Dev

How to remove all occurrences of an element from list in Python?

From Dev

Count occurrences of elements in a list until a different element appears

From Dev

Most efficient way to count occurrences?

From Dev

Row with most occurrences of a character MySQL

From Dev

Most efficient way to retrieve all element of a Dictionary from a list of keys?

From Java

The most efficient way to search every element of a list in a dataframe

From Dev

Most pythonic way to remove tuples from a list if first element is a duplicate

From Dev

Scheme/Racket: most idiomatic way to append single element to end of list

From Dev

Python: How to sort a list of lists by the most common first element?

From Dev

How do i find the percentage of the most common element in a list?

From Dev

Make a list with the most frequent tuple of a dictionary acording the first element

From Dev

How to get the most common element from a list in python

Related Related

  1. 1

    Find the element with most occurrences in a list in Racket

  2. 2

    When a draw occurs when tracking most occurrences in a list how to find element with highest index?

  3. 3

    Finding the most frequent occurrences of pairs in a list of lists

  4. 4

    Ordering a list by most occurrences of lowest number

  5. 5

    Python: Counting occurrences of List element within List

  6. 6

    How to find all occurrences of an element in a list

  7. 7

    Recursive Python function to count occurrences of an element in a list

  8. 8

    I want to count the occurrences of an element in a list

  9. 9

    How to count occurrences of specific element for arrays in a list?

  10. 10

    Count and remove the successive occurrences of the first element in a list

  11. 11

    Deleting repetitive occurrences of same element in list

  12. 12

    How to count occurrences of specific element for arrays in a list?

  13. 13

    Abstract List Functions in Racket/Scheme - Num of element occurrences in list

  14. 14

    Java-get most common element in a list

  15. 15

    C#: Get Most Occurring Element in a List?

  16. 16

    Haskell - count most repeated element in a list with interact

  17. 17

    In-place replacement of all occurrences of an element in a list in python

  18. 18

    How to remove all occurrences of an element from list in Python?

  19. 19

    Count occurrences of elements in a list until a different element appears

  20. 20

    Most efficient way to count occurrences?

  21. 21

    Row with most occurrences of a character MySQL

  22. 22

    Most efficient way to retrieve all element of a Dictionary from a list of keys?

  23. 23

    The most efficient way to search every element of a list in a dataframe

  24. 24

    Most pythonic way to remove tuples from a list if first element is a duplicate

  25. 25

    Scheme/Racket: most idiomatic way to append single element to end of list

  26. 26

    Python: How to sort a list of lists by the most common first element?

  27. 27

    How do i find the percentage of the most common element in a list?

  28. 28

    Make a list with the most frequent tuple of a dictionary acording the first element

  29. 29

    How to get the most common element from a list in python

HotTag

Archive