dsa · easy

Kth Smallest Element

GreyOrangeArrayHeapSortingFoundation

Return the k-th smallest element of unsorted nums (1-indexed).

Arguments

**Example:** nums = [7,10,4,3,20,15], k = 37.

Constraints

1 <= k <= nums.length <= 4*10^4 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[7,10,4,3,20,15]
3

Expected:
7

Example 2

Input:
[1]
1

Expected:
1

Open in the Dojo editor