Easy Java
Using string builder\n\npublic static String smallestString(String s) {\n     StringBuilder sb=new StringBuilder(s);\n     int i=0;\n     int n=s.length();\n   
Using string builder\n```\npublic static String smallestString(String s) {\n     StringBuilder sb=new StringBuilder(s);\n     int i=0;\n     int n=s.length();\n     while(i<n && sb.charAt(i)==\'a\') i++;\n     if(i==n) sb.setCharAt(n-1, \'z\');\n     while(i<n){\n        if(sb.charAt(i)!=\'a\') sb.setCharAt(i,(char)(sb.charAt(i)-1));\n        else break;\n        i++;\n     }\n     return sb.toString();\n\n     }\n```\n\n  Same approach without using string builder\n  \n```\n  public static String smallestString(String s) {\n        char[] ch=s.toCharArray();\n        int n=s.length();\n        int i=0;\n        while(i<n && ch[i]==\'a\'){\n          i++;\n        }\n        if(i==n){\n            ch[n-1]=\'z\';\n            return String.valueOf(ch);\n        }\n        while(i<n){\n            if(ch[i]!=\'a\'){\n                ch[i]-=1;\n            }\n            else{\n                break;\n            }\n            i++;\n        }\n        return String.valueOf(ch);\n    }\n```
['String', 'Java']