1576. Replace All ?'s to Avoid Consecutive Re..., Time Complexity: O(N), Space Complexity: O(1)
IntuitionApproachComplexity
Time complexity: O(N)

Space complexity: O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

- Space complexity: O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```python3 []
class Solution:
    def modifyString(self, s):
        all_chars_ords = range(97, 122 + 1)
        all_chars = [chr(o) for o in all_chars_ords]

        len_s = len(s)

        ret_val = ''

        i = 0
        while (i < len_s):
            if (s[i] == '?'):
                replaced_chars = all_chars.copy()
                prev_c = None
                if (i > 0):
                    prev_c = ret_val[i-1] # prev_c = s[i-1]
                    replaced_chars.remove(prev_c)
                next_c = None
                if (i < len(s) - 1):
                    next_c = s[i+1]
                    try:
                        replaced_chars.remove(next_c)
                    except ValueError:
                        pass
                
                ret_val += replaced_chars[0]
            else:
                ret_val += s[i]
                
            i += 1

        return ret_val
```
['Python3']