BEATS 100% JAVA SOLUTION, EASY APPROACH
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n// class Solution {\n//     public String smallestString(String s) {\n//         int n=s.length();\n//         int i=0;\n//         char ch[]=s.toCharArray();\n    \n//         while(i<n && ch[i]==\'a\')\n//         {\n//             i++;\n//             if(i==n)\n//             {\n//                 ch[i-1]=\'z\';\n//             }\n//         }\n//         while(i<n && ch[i]!=\'a\')\n//         {\n//             ch[i]=(char) (ch[i]-1);\n//             i++;\n//         }\n//         return new String(ch);\n\n//     }\n// }\nclass Solution {\n    public String smallestString(String s) {\n        StringBuilder sb = new StringBuilder(s);\n        int i=0, lnth = s.length();\n\n        while(i<lnth && s.charAt(i) == \'a\')     i++;\n\n        if(i == lnth)   sb.setCharAt(i-1,\'z\');\n\n        while(i<lnth  && s.charAt(i) != \'a\'){\n            sb.setCharAt(i, (char)((s.charAt(i))-1));\n            i++;\n        }\n\n        return sb.toString();\n    }\n}\n```
['Java']