We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Functional Programming
  3. Recursion
  4. String-o-Permute

String-o-Permute

Problem
Submissions
Leaderboard
Discussions
Editorial

Kazama gave Shaun a string of even length, and asked him to swap the characters at the even positions with the next character. Indexing starts at .

Formally, given a string str of length where is even, Shaun has to swap the characters at position and , where {}.

For example, if str = "abcdpqrs", . We have to swap the characters at positions:
{}

So, answer will be "badcqpsr".

Input Format

The first line contains an integer, , the number of test cases.
lines follow, each containing some string str.

Output Format

For each test case, print the new string as explained in the problem statement.

Constraints



is even
str consists of lowercase English characters, {}.

Sample Input

2
abcdpqrs
az

Sample Output

badcqpsr
za

Explanation

Test case #00: This is the same example as mentioned in the problem statement.
Test case #01: Here is , so we have to swap the characters at position only.

Author

abhiranjan

Difficulty

Easy

Max Score

10

Submitted By

5608

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature