s.toCharArray
Approach\ns.toCharArray\n# Complexity\n\n# Code\nkotlin []\nclass Solution {\n    fun smallestString(s: String): String {\n        val ArrChar = s.toCharArray()
# Approach\ns.toCharArray\n# Complexity\n![image.png](https://assets.leetcode.com/users/images/08c22dc7-6cc3-4dad-9522-eddbc852e819_1727702369.8424196.png)\n# Code\n```kotlin []\nclass Solution {\n    fun smallestString(s: String): String {\n        val ArrChar = s.toCharArray()\n        val len = s.length\n        var i = 0\n        while (i<len && ArrChar[i]==\'a\') i++\n        if (i==len) {\n            ArrChar[len-1]=\'z\'\n            return String(ArrChar)\n        }\n        while (i<len && ArrChar[i]!=\'a\') {\n            ArrChar[i]=ArrChar[i]-1\n            i++\n        }\n        return String(ArrChar)\n    }\n}\n```
['Kotlin']