Java Easy Single Iteration ✅🔥
Code\n\nclass Solution {\n    public String smallestString(String s) {\n        int length = s.length();\n        char[] chars = s.toCharArray();\n        int i
# Code\n```\nclass Solution {\n    public String smallestString(String s) {\n        int length = s.length();\n        char[] chars = s.toCharArray();\n        int ind = 0;\n\n        // Check if the input string consists only of \'a\' characters\n        boolean allA = true;\n        for (int i = 0; i < length; i++) {\n            if (chars[i] != \'a\') {\n                allA = false;\n                break;\n            }\n        }\n\n        if (allA) {\n            chars[length-1] = \'z\'; // Replace the first \'a\' with \'z\'\n        } else {\n            // Find the first non-\'a\' character and decrease it\n            while (ind < length && chars[ind] == \'a\') {\n                ind++;\n            }\n\n            while (ind < length && chars[ind] != \'a\') {\n                chars[ind] = (char) (chars[ind] - 1);\n                ind++;\n            }\n        }\n\n        return new String(chars);\n    }\n}\n```
['Two Pointers', 'String', 'Java']