Sales by Match

  • + 0 comments

    C#

    public static int sockMerchant(int n, List<int> ar)
        {
            var orderArray = ar.Order().ToList();
            
            var sets = orderArray.GroupBy(n => n).ToList();
            
            int countPairs = 0;
            
            sets.ForEach(s => countPairs += s.ToList().Count() / 2);
            
            return countPairs;
        }