New update is available. Click here to update.

Last Updated: 26 Mar, 2021

Difficulty: Moderate

```
If ‘x’ is even then ‘x’ will become ‘x / 2’.
If ‘x’ is odd then ‘x’ will become ‘x * 3 + 1’.
```

```
Let’s say you have an array/list [1, 3, 4, 5] and ‘K’=2. The factor values are [0, 7, 2, 5] respectively. Finally, our array will look like [1, 4, 5, 3]. Since ‘K’ is 2 return 4.
```

```
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains two space-separated integers ‘N’ and ‘K’ representing the size of the array/list ‘ARR’ and position whose value in the sorted list you need to return.
The second line and the last line of input contain ‘N’ single space-separated integers representing the array/list elements.
```

```
For each test case, print a single line containing a single integer denoting the ‘K-th’ element in sorted list.
The output of each test case will be printed in a separate line.
```

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

```
1 <= T <= 10
1 <= N <= 1000
1 <= K <= N
1 <= ‘ARR[i]’ <= 10 ^ 4
Where ‘ARR[i]’ is an element of array/list ARR.
Time Limit: 1sec
```

SIMILAR PROBLEMS

Missing Number

Posted: 30 Oct, 2022

Difficulty: Easy

Longest Subarray With Zero Sum

Posted: 3 Nov, 2022

Difficulty: Moderate

Merge Two Sorted Arrays Without Extra Space

Posted: 19 Nov, 2022

Difficulty: Moderate

Ninja And The Strictly Increasing Array

Posted: 27 Nov, 2022

Difficulty: Moderate

Negative To The End

Posted: 16 Dec, 2022

Difficulty: Easy

Popular Interview Problems: