New update is available. Click here to update.

Posted: 25 Feb, 2021

Difficulty: Easy

```
If ‘N’ = 5 and K = 2
[1, 2, 3, 4, 5]
Then the output will be [1, 4, 3, 2, 5].
```

```
The first line of input contains an integer T denoting the number of test cases.
The first line of each test case contains two space-separated integers N, and K, where N is the number of elements of the array and K is the index.
The second line of each test case contains ‘N’ space-separated integers, denoting the array elements.
```

```
For each test case, print the array after swapping the Kth element from the start and the Kth element from the end.
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 given function.
```

```
1 <= T <= 5
1 <= K < N <= 5000
Time Limit : 1 sec
```

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: