Persistent Coding Questions and Answer in 2022
Problem
Statement :
Sajith
loves numbers and coding. His dad gives a task to write a code to find the nth
largest number in an array.
Input
- The
inputs have : First the count of integers and the second n value
- The
second line of the input has the list of integers that he needs to do the
operations upon.
Output
- You
have to print the integer representing the nth largest out of the numbers
given by his father
Constraints
- 0
< value n <= count of integers <= 10^6
- -10^6
<= each integer <= 10^6
- 0
<= i < count of integers
Example
Input
5 3
11 -1 – 4 12 -6
Output
-1
Explanation :
-1 is 3rd
largest
Program :
n,k=map(int,input("Enter a Numbers :
").split())
print(sorted(list(map(int,input("list of Integer : ").split())))[-k])
for execution and output so check the video :
Comments
Post a Comment