Simple solution
\n\nclass Solution {\n    public String smallestString(String s) {\n     StringBuilder ans=new StringBuilder();\n     if(s.charAt(0)!=\'a\'){\nint j=0;\n      w
\n```\nclass Solution {\n    public String smallestString(String s) {\n     StringBuilder ans=new StringBuilder();\n     if(s.charAt(0)!=\'a\'){\nint j=0;\n      while(j<s.length()&&s.charAt(j)!=\'a\'){\n          ans.append((char)(s.charAt(j)-1));\n           j++;\n      }\n      for(int i=j;i<s.length();i++){\n        ans.append(s.charAt(i));\n      }\n     \n     return ans.toString();\n     }\n     else{\n        int j=0;\n      while(j<s.length()&&s.charAt(j)==\'a\'){\n        j++;\n        ans.append(\'a\');\n      }\n      if(j==s.length()){\n        ans.replace(s.length()-1,s.length(),\'z\'+"");\n        return ans.toString();\n      }\n      else{\n       // ans+=s.substring(0,j);\n       /* for(int i=j;i<s.length();i++){\n            ans+=(char)(s.charAt(i)-1);\n        }*/\n        while(j<s.length()&&s.charAt(j)!=\'a\'){\n             ans.append((char)(s.charAt(j)-1));\n             j++;\n        }\n        for(int i=j;i<s.length();i++)ans.append(s.charAt(i));\n        return ans.toString();\n      }\n     }\n    }\n}\n```
['Java']