Company: Goldman Sachs_15 july
Difficulty: medium
Smallest String Problem Description Given a string s of lowercase English letters, select exactly one non-empty substring and replace each character with the previous character in the English alphabet. For example, 'b' becomes 'a', 'c' becomes 'b', and 'a' becomes 'z'. Find the alphabetically smallest string that can be obtained after performing this operation exactly once. Complete the function getSmallestString in the editor with the following parameter: s: a string Return: string: the alphabetically smallest string possible Examples Example 1: Input: s = "hackerrank" Output: gackerrank Explanation: Selecting and changing only the first character produces 'gackerrank', which is the alphabetically smallest string possible. Example 2: Input: s = "bbcad" Output: aacbd Explanation: Change 'bb' to 'aa'. Example 3: Input: s = "ab" Output: aa Explanation: Change 'b' to 'a'. Constraints 1 5