#K63602. K-th Smallest Element

    ID: 31790 Type: Default 1000ms 256MiB

K-th Smallest Element

K-th Smallest Element

You are given an array of N integers and an integer k. Your task is to determine the k-th smallest element in the array after sorting it in ascending order.

Note: The array may contain duplicate elements.

Constraints:

  • \(1 \leq N \leq 10^5\)
  • \(1 \leq arr[i] \leq 10^9\)
  • \(1 \leq k \leq N\)

Read input from stdin and write output to stdout.

inputFormat

The first line contains an integer N, representing the number of elements in the array. The second line contains N space-separated integers denoting the elements of the array. The third line contains an integer k, the position (1-indexed) of the smallest element to find.

outputFormat

Output the k-th smallest element from the sorted array.## sample

5
3 1 4 1 5
3
3

</p>