Simple java solution | index of first non 'a' character
\nclass Solution {\n    public String smallestString(String s) {\n        char[] chars = s.toCharArray();\n        int n = chars.length;\n        boolean replac
```\nclass Solution {\n    public String smallestString(String s) {\n        char[] chars = s.toCharArray();\n        int n = chars.length;\n        boolean replace = false;\n        for (int i = 0; i < n; i++) {\n            if(chars[i]==\'a\'){\n                if(replace){\n                    break;\n                }\n                continue;\n            }\n            replace = true;\n            chars[i] = (char) (chars[i]-1);\n        }\n        if(!replace){\n            chars[n-1] = \'z\';\n        }\n        return new String(chars);\n    }\n}\n```
['Java']