Problems > Pairwise Swap

Pairwise Swap

Difficulty: 800 2000 ms 128 MB

strings

Swap characters pairwise: positions 1↔2, 3↔4, ... A trailing unpaired character stays put.

Input: one line with the string S.

Output: the pair-swapped string.

Constraints:

  • 1 ≤ |S| ≤ 104

Sample Tests

Input 1
abcde
Output 1
badce
Input 2
ab
Output 2
ba

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.