Easy Solution for beginners ||  Beats 95%+✨💫 ||  🧛✌️
Intuition\nIt seems that you want to replace the question mark (\'?\') in the input string \'s\' with lowercase English alphabets (\'a\' to \'z\') in such a way
# Intuition\nIt seems that you want to replace the question mark (\'?\') in the input string \'s\' with lowercase English alphabets (\'a\' to \'z\') in such a way that adjacent characters are not the same. The code uses a dictionary to keep track of the positions of the question marks and then iterates through the string to perform replacements based on certain conditions.\n\n# Approach\nThe approach followed in the code is to iterate through the positions of the question marks in the string \'s\'. For each position, it tries to replace the question mark with a lowercase English alphabet that is different from its adjacent characters (if any).\n\n# Complexity\n- Time complexity: O(n)\n\n- Space complexity: O(n)\n\n# Code\n```\nclass Solution:\n    def modifyString(self, s: str) -> str:\n        alp=\'abcdefghijklmnopqrstuvwxyz\'\n        #print(dic)\n        d=defaultdict(list)\n        for i in range(len(s)):\n            if s[i]==\'?\':\n                d[s[i]].append(i)\n        #print(d)\n        if len(s)==1:\n            return "a"\n        for j in d[\'?\']:\n            if j > 0 and j < len(s)-1:\n                for k in alp:\n                    if s[j-1] != k and s[j+1] != k:\n                        #print(s)\n                        s=s[:j] + k + s[j+1:]\n                        break\n            elif j == 0 and len(s) != 1:\n                for k in alp:\n                    if s[j+1] != k:\n                        #print(k)\n                        s=k+s[j+1:]\n                        break\n            elif j == len(s)-1:\n                for k in alp:\n                    if s[j-1] != k:\n                        #print(k)\n                        s=s[:j] + k\n                        break\n        return s\n```
['String', 'Python3']