Java O(n) | 100%
We do not need more than 3 letters to build a non-repeating character sequence.\n\n# Code\n\nclass Solution {\n    public String modifyString(String s) {\n\n   
**We do not need more than 3 letters to build a non-repeating character sequence.**\n\n# Code\n```\nclass Solution {\n    public String modifyString(String s) {\n\n        if(s.length()==1) return s.equals("?")?"a":s;\n\n        char[] ch = s.toCharArray();\n\n        for(int i=1;i<ch.length-1;i++){\n            if(ch[i]==\'?\'){\n                if(ch[i-1]!=\'a\' && ch[i+1]!=\'a\') ch[i]=\'a\';\n                else if(ch[i-1]!=\'b\' && ch[i+1]!=\'b\') ch[i]=\'b\';\n                else if(ch[i-1]!=\'c\' && ch[i+1]!=\'c\') ch[i]=\'c\';\n            }\n        }\n\n        if(ch[0]==\'?\')\n            ch[0]=ch[1]==\'a\'?\'b\':\'a\';\n\n        if(ch[ch.length-1]==\'?\')\n            ch[ch.length-1]=ch[ch.length-2]==\'a\'?\'b\':\'a\';\n\n        return new String(ch);\n    }\n}\n```
['Java']