Company: Amazon_31_jan
Difficulty: medium
Optimal Data Encryption Optimal Data Encryption Problem Description Engineers at a cloud storage provider are building a new data-protection module for the company's cloud platform. One of its jobs is to encrypt incoming data. The encryption works by picking some substring of the data and right-rotating that substring by 1 position, exactly once. The substring must be chosen so that the resulting encrypted data is the alphabetically smallest string obtainable this way. Here, right rotating a string a by 1 position means shifting every character of a one step to the right, then taking the character that falls off the end and placing it at the front of a . For example, if a = "ahssd" , after right rotation by 1 position, a becomes "dahss" . Given the input input_text as a string, find the encrypted data. Note: A string x is alphabetically smaller than string y , if either x is a prefix of y (and x ≠ y ), or there exists such i (0 ≤ i < min(|x|, |y|)), that x[i] < y[i] , and for any