💻✅BEATS 100%⌛⚡[C++/Java/Py3/JS]🍨| EASY n CLEAN EXPLANATION⭕💌
IntuitionThe problem requires replacing each '?' in the given string with a lowercase English letter such that no two adjacent characters are the same. Since th
# Intuition
The problem requires replacing each `'?'` in the given string with a lowercase English letter such that no two adjacent characters are the same. Since there are only 26 possible letters, we can greedily replace `'?'` with the smallest possible letter that does not match its adjacent characters.

# Approach
1. Traverse the string character by character.
2. If a character is `'?'`, determine the possible letters that do not match its left and right adjacent characters.
3. Select the smallest valid letter (`'a'`, `'b'`, or `'c'` should be enough).
4. Replace `'?'` with this letter and continue.
5. Return the modified string.

### Steps:
- Iterate through the string.
- If `s[i]` is `'?'`:
  - Find `s[i-1]` (left character) if it exists.
  - Find `s[i+1]` (right character) if it exists.
  - Choose a replacement character (`'a'`, `'b'`, or `'c'`) that is not the same as `left` or `right`.
  - Assign this character to `s[i]`.
- Continue until all `'?'` are replaced.

# Complexity
- **Time Complexity**: `O(n)`, as we traverse the string once.
- **Space Complexity**: `O(1)`, as we modify the string in place.

# Code

```C++ []
class Solution {
public:
    string modifyString(string s) {
        int n = s.length();

        for (int i = 0; i < n; i++) {
            if (s[i] == '?') {
                char left = (i > 0) ? s[i - 1] : ' ';
                char right = (i + 1 < n) ? s[i + 1] : ' ';
                s[i] = (left != 'a' && right != 'a')? 'a' : (left != 'b' && right != 'b')? 'b' : 'c';
            }
        }return s;
    }
};
```
```python []
class Solution:
    def modifyString(self, s: str) -> str:
        s = list(s)
        n = len(s)

        for i in range(n):
            if s[i] == '?':
                left = s[i - 1] if i > 0 else ' '
                right = s[i + 1] if i + 1 < n else ' '

                if left != 'a' and right != 'a':
                    s[i] = 'a'
                elif left != 'b' and right != 'b':
                    s[i] = 'b'
                else:
                    s[i] = 'c'

        return "".join(s)
```
```java []
class Solution {
    public String modifyString(String s) {
        char[] arr = s.toCharArray();
        int n = arr.length;

        for (int i = 0; i < n; i++) {
            if (arr[i] == '?') {
                char left = (i > 0) ? arr[i - 1] : ' ';
                char right = (i + 1 < n) ? arr[i + 1] : ' ';

                if (left != 'a' && right != 'a') arr[i] = 'a';
                else if (left != 'b' && right != 'b') arr[i] = 'b';
                else arr[i] = 'c';
            }
        }
        return new String(arr);
    }
}
```
```javascript []
/**
 * @param {string} s
 * @return {string}
 */
var modifyString = function(s) {
    let arr = s.split('');
    let n = arr.length;

    for (let i = 0; i < n; i++) {
        if (arr[i] === '?') {
            let left = (i > 0) ? arr[i - 1] : ' ';
            let right = (i + 1 < n) ? arr[i + 1] : ' ';

            arr[i] = (left !== 'a' && right !== 'a') ? 'a' :
                     (left !== 'b' && right !== 'b') ? 'b' : 'c';
        }
    }
    return arr.join('');
};

```
✨ AN UPVOTE WILL BE APPRECIATED ^_~ ✨
```
['String', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']