Eas Solution || 93%
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```java []\nclass Solution {\n    public String smallestString(String s) {\n        StringBuilder sb=new StringBuilder();\n        int n=s.length();\n        int i=0;\n        while(i<n && s.charAt(i)==\'a\')\n           i++;\n           sb.append(s.substring(0,i));\n           if(i==n)\n           return s.substring(0,n-1)+\'z\';\n        while(i<n && s.charAt(i)!=\'a\')\n        { sb.append((char)(s.charAt(i)-1));\n         i++;}\n         sb.append(s.substring(i));\n         return sb.toString();\n    }\n}\n```
['Java']