1 line C#


  • 0
    B
    public class Solution {
        public string FrequencySort(string s) {
            return new String(s
                .GroupBy(c => c)
                .Select(g => new {Char = g.Key, Count = g.Count()})
                .OrderByDescending(pair => pair.Count)
                .SelectMany(pair => Enumerable.Range(0, pair.Count).Select(_ => pair.Char))
                .ToArray()
            );
        }
    }
    

Log in to reply
 

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