K-th Smallest (Quickselect)

JavaScript Hard 4 views
Back to Questions

Problem Description

Given an array and integer k, find the k-th smallest element (1-based) without fully sorting.

Input Format

Line1: n k. Line2: n integers.

Output Format

One integer answer.

Sample Test Case

Input:
7 3 7 2 1 6 8 5 3
Output:
3

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev