AlgoUniversity
  • Go Back
Discussion
Kth Smallest Element :

Author

Ujjwal Srivastava

Difficulty Level : Easy

Submissions : 159

Asked In : Samsung

Marks :10

: 0 | : 0

Given an array and a number $$$K$$$ where $$$K$$$ is smaller than the size of the array. Find the $$$K_{th}$$$ smallest element in the given array. Given that all array elements are distinct.

Input

The first line contains an integer $$$N$$$ denoting the length of the array and an integer $$$K$$$ separated by a space. The second line contains $$$N$$$ separated integers $$$A_{i}$$$ denoting the array.$$$(1 \le N,A_{i} \le 10^5)$$$$$$(1\le K \le N).$$$

Output

Output the $$$K_{th}$$$ smallest element.

Examples

Input
5 4
1 33 22 77 3
Output
33
Input
1 1
2
Output
2
Input
2 1
3 1
Output
1

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.