JAVA | Easy solution ✅
Please Upvote :D\njava []\nclass Solution {\n    public String modifyString(String s) {\n        if (s.equals("?")) {    // edge case\n            return "a";\n
# Please Upvote :D\n``` java []\nclass Solution {\n    public String modifyString(String s) {\n        if (s.equals("?")) {    // edge case\n            return "a";\n        }\n\n        char[] a = s.toCharArray();\n        for (int i = 0; i < a.length; i++) {\n            if (a[i] == \'?\') {\n                // corner case 1\n                if (i == 0) {   \n                    // look for character until its unequal \n                    // with character at index i+1\n                    for (char c = \'a\'; c <= \'z\'; c++) {\n                        if (c != a[i+1]) {\n                            a[i] = c;\n                            break;\n                        }\n                    }\n                } \n                // corner case 1\n                else if (i == a.length - 1) {   \n                    // look for character until its unequal \n                    // with character at index i-1\n                    for (char c = \'a\'; c <= \'z\'; c++) {\n                        if (c != a[i-1]) {\n                            a[i] = c;\n                            break;\n                        }\n                    }\n                } \n                // regular case\n                else {\n                    // look for character until its unequal \n                    // with characters at indices i-1 and i+1\n                    for (char c = \'a\'; c <= \'z\'; c++) {\n                        if (c != a[i+1] && c != a[i-1]) {\n                            a[i] = c;\n                            break;\n                        }\n                    }\n                }\n            }\n        }\n\n        return new String(a);\n    }\n}\n```\n---\n#### Shorter solution:\n``` java []\nclass Solution {\n    public String modifyString(String s) {   \n        char[] a = s.toCharArray();\n        for (int i = 0; i<a.length; i++) {\n            if (a[i] == \'?\') {\n                for (char c = \'a\'; c <= \'z\'; c++) {\n                    a[i] = c;\n                    if (i > 0 && a[i-1] == c) {\n                        continue;\n                    }\n                    if (i < a.length - 1 && a[i+1] == c) {\n                        continue;\n                    }\n                    break;\n                }\n            }\n        }\n        \n        return new String(a);\n    }\n}\n```\n---\n**Time Complexity:** $$O(n * 26) => O(n)$$\n**Space Complexity:** $$O(n)$$\n---
['String', 'Java']