Thank you for such a detailed explanation! I do have a question – doesn’t the first example, kthLargest1, find the kth smallest element in the array?
]]>Did you consider the duplicate values case? It seems when you check the kth element, the duplicate values cause problems because 7th element may not be the 7th largest element if it contains duplicates before it. For example, [44,23,19,19,13,19, 10(pivot) , 4,5,6,8], although 10 is the 7th element it is the 5th largest element.
]]>