Swap Nodes in Pairs

Medium
Linked Lists Linked List Recursion

Swap every two adjacent nodes. Print resulting list.

Constraints

Nodes ≤ 100

Examples

Example 1:
Input: 1 2 3 4
Output: 2 1 4 3
Example 2:
Input:
Output:
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.