From 89649592cd27b626fa3c7057ac7addc8b5696467 Mon Sep 17 00:00:00 2001 From: PaulyMac Date: Thu, 7 Mar 2019 13:08:06 +0000 Subject: [PATCH] Added Kth Largest --- KthLargest/KthLargest.kt | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100755 KthLargest/KthLargest.kt diff --git a/KthLargest/KthLargest.kt b/KthLargest/KthLargest.kt new file mode 100755 index 0000000..5650690 --- /dev/null +++ b/KthLargest/KthLargest.kt @@ -0,0 +1,8 @@ +import java.util.* +fun findKthLargest(nums: IntArray, k: Int): Int { + Arrays.sort(nums) + return nums[nums.size - k] +} +fun main(args: Array) { + println(findKthLargest(intArrayOf(3,2,1,5,6,4), 2)) +} \ No newline at end of file