Company: Expedia
Difficulty: medium
Design an encryption algorithm that transforms the string originalString according to the following rules: Initialize two empty strings: temporaryString and encryptedString . At each step, perform one of the following operations to achieve the alphabetically smallest possible encryptedString : Operation 1 - take the first character from originalString and append it to the end of temporaryString . Operation 2 - take the last character from temporaryString and append it to the end of encryptedString . The process ends when both originalString and temporaryString are empty. Given a string originalString , print the resulting encryptedString . Note: A string a is alphabetically smaller than string b if, at the first differing position, the character in a appears earlier in the alphabet than the corresponding character in b . Input Format A single line containing the string originalString . Output Format Print a single line containing the encrypted string. Constraints 1 ≤ |originalString