Want to solve this problem? Login now to get access to solve the problems

Problem

Submissions

Solution

Leaderboard

Coming soon

1

Difficulty: EASY

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

Suggest Edit

```
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows.
The first line of each test case contains two space-separated integers ‘N’ representing the size of the array and ‘K’.
The second line contains N space-separated integers that represent elements of the array ARR.
```

```
For each test case, return the Kth smallest element of the array
```

```
You do not need to print anything; it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 100
1 <= N <=10^4
1 <= K <= N
1 <= ARR[i] <= 10^9
Time limit: 1 second
```

```
3
6 3
1 2 3 4 5 6
5 4
1 3 8 6 2
1 1
5
```

```
3
6
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.
```

```
3
2 2
1 14
2 1
1 14
3 2
6 7 9
```

```
14
1
7
```

```
(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.
```

Want to solve this problem? Login now to get access to solve the problems