Swap kth elements
Submissions: 7914   Accuracy:


  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!

Given an array of size N, swap the kth element from beginning with kth element from end.

The first line of input contains an integer T denoting the number of test cases. T testcases follow. Each testcase contains 2 lines of input:
The first line contains an integer N, where N is the size of array.
The second line contains N integers(elements of the array) sperated with spaces.

For each test case, print the modified array.

1 ≤ T ≤ 200
1 ≤ K ≤ N ≤ 500
1 ≤ A[i] ≤ 1000

8 3
1 2 3 4 5 6 7 8

1 2 6 4 5 3 7 8


** For More Input/Output Examples Use 'Expected Output' option **

Author: rajatjha

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.