New update is available. Click here to update.
Close
Topic list
Kth Smallest Element
EASY
15 mins
Sorting
Arrays
Heap
Topics (Covered in this problem)
Problem solved
Skill meter
Sorting
-
-
Arrays
-
-
Heap
-
-
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
SQL
-
-
Binary Search Trees
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

# Kth Smallest Element

Contributed by
Ankush Gupta
Easy
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

#### Note: All the elements in the array are distinct.

Detailed explanation ( Input/output format, Notes, Constraints, Images )
##### Sample Input 1:
``````3
6 3
1 2 3 4 5 6
5 4
1 3 8 6 2
1 1
5
``````
##### Sample Output 1:
``````3
6
1
``````
##### Explanation of Input 1:
``````(i) Sorted array will be 1 2 3 4 5 6, this shows that 3 is the third-smallest element in the array.
(ii) Sorted array will be 1 2 3 6 8, this shows that 6 is the fourth-smallest element in the array.
(iii) Sorted array will be 5, this shows that 5 is the smallest (and only) element in the array.
``````
##### Sample Input 2:
``````3
2 2
1 14
2 1
1 14
3 2
6 7 9
``````
##### Sample Output 2:
``````14
1
7
``````
##### Explanation of Input 2:
``````(i) Sorted array will be 1 14, this shows that 14 is the second-smallest element in the array.
(ii) Sorted array will be 1 14, this shows that 1 is the smallest element in the array.
(iii) Sorted array will be 6 7 9, this shows that 7 is the second-smallest element in the array.
``````
Auto
Console