All Tracks Algorithms String Algorithms Basics of String Manipulation Problem

Decode
Tag(s):

Algorithms, Easy, String, String Manipulation

Problem
Editorial
Analytics

Given an encrypted message, Erwin encodes it the following way:

Removes the median letter of the word from the original word and appends it to the end of the encrypted word and repeats the process until there are no letters left.

A median letter in a word is the letter present in the middle of the word and if the word length is even, the median letter is the left one out of the two middle letters.

Given an encoded string, write a program to decode it.

Input Format:

The first line of input contains T, the number of test cases.
Each test case contains a String S, denoting the encoded word.

Output Format:

Print the decoded word for each test case in a separate line.

Constraints

\(1 \le T \le 100 \)
\(1 \le |S| \le 100000 \)

SAMPLE INPUT
2
wrien
reen
SAMPLE OUTPUT
erwin
eren
Explanation

In the first test case, Erwin encoded the String "erwin". At first, he wrote down the letter 'w' after which the string became "erin", he then wrote down 'r' and the remaining string was "ein", he then wrote 'i' and the string became "en" and so on he wrote down 'e' and 'n' to get the encoded string as "wrien".

Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Accolite

Challenge Name

Accolite Java Hiring Challenge

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?