Simple explanation with start and end indices [Python]
IntuitionWhen we convert any character before the first 'a', the string still remains lexographically smaller, so the idea is to find first index of 'a' after w
# Intuition
When we convert any character before the first 'a', the string still remains lexographically smaller, so the idea is to find first index of 'a' after we changed any non 'a' character. This index will give us the 'end' till where we need to take the substring. If there is no such character found, then take end as the last index by default.

# Approach
1. Take start as -1 and end as len(s) (not taking -1 as it will be easy to use slice later)
2. Iterate through the string and when you find the first non 'a' character, fix it as the start
3. In the same iteration when you find the first 'a' character after we already fixed a start, take it as the end and break the loop. We don't have to process anymore as we got the start and end.
4. We need a check in step 3 to also check if start exists because we should only find 'a' after a non 'a'. Ex: 'aaa' -> we cannot take the first 'a' as end.
5. We have the start and end, so we need to convert only that part of substring and keep the remaining part same.

# Complexity
- Time complexity: O(N)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(N) considering the new converted string
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def convert(self, s):
        res = ""
        for c in s:
            if c == "a":
                res += "z"
            else:
                res += chr(ord(c) - 1)
        return res

    def smallestString(self, s: str) -> str:
        start = -1
        end = len(s)
        for i in range(len(s)):
            if s[i] != "a" and start == -1:
                start = i
            if s[i] == "a" and start != -1:
                end = i
                break
        
        print(start, end)
        return s[0:start]+self.convert(s[start:end])+s[end:]
```
['Python3']