662. Swap Adjacent Nodes in a Linked List
0
Medium
Given a singly linked list of size N, swap every two adjacent nodes in the linked list without changing their values.
Input Format
The first line contains an integer N, which represents the size of the singly linked list. The second line contains N space-separated integers representing the elements of the linked list.
Output Format
Print the modified linked list.
Example
Input
5
1 2 3 4 5
Output
2 1 4 3 5
Constraints
0 <= N <= 200000
Elements in the linked list range from -1000000000 to 1000000000
Loading...
View Submissions
Console