C# super clean solution using SortedList


  • 0
    I
        public int FindKthLargest(int[] nums, int k) {
            var heap = new SortedList<int, int>(new DuplicateDescendingKeyComparer<int>());
            
            foreach(var number in nums)
            {
                heap.Add(number, number);
            }
            
            return heap.ElementAt(k - 1).Key;
        }
    

Log in to reply
 

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