Multiple swaps

Report a typo

Write a program to sequentially swap elements by their indexes in a given list. Indexes of the elements start with 0 and are always less than the size of the list.

Try to use standard methods for processing collections.

Input data format

The first line contains elements of the list. The second line contains the number of swaps. Then follow the lines with descriptions of the swaps. Each line contains two numbers: indexes of swapped elements.

Output data format

All elements of the modified list separated by spaces must be output in one line.

Sample Input 1:

1 2 3 4 5 6
2
0 1
3 5

Sample Output 1:

2 1 3 6 5 4
Write a program in Java 17
class Main {
public static void main(String[] args) {
// put your code here
}
}
___

Create a free account to access the full topic