Company: Expedia_12thjuly
Difficulty: medium
Encrypting Strings Problem Description An encryption routine transforms a string originalString with the help of two more strings, temporaryString and encryptedString , which both start empty. At every step the routine performs exactly one of these two operations: Operation 1: remove the first character of originalString and append it to the end of temporaryString . Operation 2: remove the last character of temporaryString and append it to the end of encryptedString . The routine stops when originalString and temporaryString are both empty. At that point encryptedString contains every character of originalString exactly once. Among all possible sequences of operations, choose the one that makes encryptedString alphabetically smallest, and return that encryptedString . A string a is alphabetically smaller than a string b of the same length if, at the first position where they differ, the character of a comes earlier in the alphabet than the character of b . Complete the function getEncr