Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element.
Input:
Array : [3,2,1,5,6,4]
Kth : 2
Output: 5
def Kth(arr,k): L=sorted(arr,reverse=True) return L[k-1] A=list(map(int,input("Nums : ").split(' '))) #or A=[3,2,1,5,6,4] K=int(input("Kth : ")) print(Kth(A,K))
Input_1:
Nums : 3 2 1 5 6 4
Kth : 2
Output:
5
Input_2:
Nums : 3 2 3 1 2 4 5 5 6
Kth : 4
Output:
4
Illustration of the Output:
![](http://www.fcukthecode.com/wp-content/uploads/2021/12/Screenshot-from-2021-12-05-19-03-48-1024x301.png)
More Q
- Determine if a person could attend all meetings in given interval times.
- Find the volume of a volley ball
- Find the maximum score obtained at the end of colour chess grid game.
- Find the number of pairs if positive integers with condition is even.
- Return the largest subset such that every pair meets the given condition.
- Find the number of index triplets that satisfy given condition.
- Handling multiple queries using array – sum, update, range.
- Find all the sequences that occur more than once in DNA molecule.
- Find the biggest number.
- Sum of cube of each number is again equal to the number then it is an Armstrong number.
- Hello World.
- Calculate the Cube Root.
- Find the count of consecutive 1’s present in array.
- Return an array with athletes relative ranks according to the score.
- Return a string of its base 7 representation.
- Return kth largest element in sorted order.
- Find all repeated elements in the array.
- Find atleast one duplicate number in the array.
- Find the maximum result of = a XOR b.