question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
score-of-a-string
Easy 3 line code
easy-3-line-code-by-nithilab2106-lzat
IntuitionThe question asked us to find the absolute difference of each letter with the next and sum up all these diffrencesApproachWhen we try storing a charcte
nithilab2106
NORMAL
2025-01-14T14:06:09.089564+00:00
2025-01-14T14:06:09.089564+00:00
98
false
# Intuition The question asked us to find the absolute difference of each letter with the next and sum up all these diffrences <!-- Describe your first thoughts on how to solve this problem. --> # Approach When we try storing a charcter in an integer varaible or perform mathematical functions java automatically conve...
1
0
['String', 'Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
C++/Python O(n)
cpython-on-by-votrubac-4o9o
We do not need more than 3 letters to build a non-repeating character sequence.\n\nFor Python, we can use set difference to determine which one to use.\n\nPytho
votrubac
NORMAL
2020-09-06T04:01:02.465128+00:00
2020-09-06T04:59:25.577416+00:00
10,276
false
We do not need more than 3 letters to build a non-repeating character sequence.\n\nFor Python, we can use set difference to determine which one to use.\n\n**Python**\n```python\ndef modifyString(self, s: str) -> str:\n\tres, prev = "", \'?\'\n\tfor i, c in enumerate(s):\n\t\tnext = s[i + 1] if i + 1 < len(s) else \'?\'...
117
1
[]
11
replace-all-s-to-avoid-consecutive-repeating-characters
Java Simple O(n) loop
java-simple-on-loop-by-hobiter-2uqh
for each char, just try \u2018a\u2019, \u2018b\u2019, \u2018c\u2019, and select the one not the same as neighbors.\n\n\n public String modifyString(String s)
hobiter
NORMAL
2020-09-06T04:01:14.868400+00:00
2020-09-06T04:01:14.868459+00:00
8,211
false
for each char, just try \u2018a\u2019, \u2018b\u2019, \u2018c\u2019, and select the one not the same as neighbors.\n\n```\n public String modifyString(String s) {\n char[] arr = s.toCharArray();\n for (int i = 0; i < arr.length; i++) {\n if (arr[i] == \'?\') {\n for (int j = 0...
81
3
[]
7
replace-all-s-to-avoid-consecutive-repeating-characters
[Python3] one of three letters
python3-one-of-three-letters-by-ye15-qqaj
\n\nclass Solution:\n def modifyString(self, s: str) -> str:\n s = list(s)\n for i in range(len(s)):\n if s[i] == "?": \n
ye15
NORMAL
2020-09-06T04:02:34.600206+00:00
2020-09-06T04:02:34.600246+00:00
4,825
false
\n```\nclass Solution:\n def modifyString(self, s: str) -> str:\n s = list(s)\n for i in range(len(s)):\n if s[i] == "?": \n for c in "abc": \n if (i == 0 or s[i-1] != c) and (i+1 == len(s) or s[i+1] != c): \n s[i] = c\n ...
79
1
['Python3']
8
replace-all-s-to-avoid-consecutive-repeating-characters
c++ | 0ms Code | easy to understand | with explanation
c-0ms-code-easy-to-understand-with-expla-qb7x
\n\'\'\'\n\n\t\tclass Solution {\n\t\tpublic:\n\t\tstring modifyString(string s) {\n int n = s.length();\n for(int i=0;i<n;i++){\n \n
pranjalmittal21
NORMAL
2020-09-07T09:10:08.596855+00:00
2020-09-24T09:25:30.018041+00:00
2,094
false
\n\'\'\'\n\n\t\tclass Solution {\n\t\tpublic:\n\t\tstring modifyString(string s) {\n int n = s.length();\n for(int i=0;i<n;i++){\n \n //checking every character, if character is \'?\'\n if(s[i] == \'?\'){\n \n //loop over every alphabet\n ...
29
0
['C', 'C++']
5
replace-all-s-to-avoid-consecutive-repeating-characters
Super easy solution, O(n), beats 100%
super-easy-solution-on-beats-100-by-eaim-44wt
\npublic String modifyString(String s) {\n if (s == null || s.isEmpty()) return "";\n \n char[] chars = s.toCharArray();\n for (int i=0; i<chars.len
eaiman
NORMAL
2020-09-06T07:11:09.432675+00:00
2020-09-06T07:11:38.793083+00:00
3,524
false
```\npublic String modifyString(String s) {\n if (s == null || s.isEmpty()) return "";\n \n char[] chars = s.toCharArray();\n for (int i=0; i<chars.length; i++) {\n if (chars[i] == \'?\') {\n for (char j=\'a\'; j<=\'z\'; j++) {\n chars[i] = j;\n if (i>0 && cha...
21
0
['Java']
6
replace-all-s-to-avoid-consecutive-repeating-characters
Python simple solution
python-simple-solution-by-tovam-kwxf
Python :\n\n\ndef modifyString(self, s: str) -> str:\n\ts = list(s)\n\n\tfor i in range(len(s)):\n\t\tif s[i] == \'?\':\n\t\t\tfor c in "abc":\n\t\t\t\tif (i ==
TovAm
NORMAL
2021-11-03T22:52:46.999158+00:00
2021-11-03T22:52:46.999201+00:00
1,333
false
**Python :**\n\n```\ndef modifyString(self, s: str) -> str:\n\ts = list(s)\n\n\tfor i in range(len(s)):\n\t\tif s[i] == \'?\':\n\t\t\tfor c in "abc":\n\t\t\t\tif (i == 0 or s[i - 1] != c) and (i + 1 == len(s) or s[i + 1] != c):\n\t\t\t\t\ts[i] = c\n\t\t\t\t\tbreak\n\n\treturn "".join(s)\n```\n\n**Like it ? please upvot...
12
0
['Python', 'Python3']
1
replace-all-s-to-avoid-consecutive-repeating-characters
C#
c-by-mhorskaya-7x0o
\npublic string ModifyString(string s) {\n\tvar chars = s.ToArray();\n\n\tfor (var i = 0; i < s.Length; i++) {\n\t\tif (chars[i] != \'?\') continue;\n\n\t\tvar
mhorskaya
NORMAL
2020-09-09T10:29:27.969362+00:00
2020-09-09T10:29:27.969392+00:00
429
false
```\npublic string ModifyString(string s) {\n\tvar chars = s.ToArray();\n\n\tfor (var i = 0; i < s.Length; i++) {\n\t\tif (chars[i] != \'?\') continue;\n\n\t\tvar left = i > 0 ? chars[i - 1] : (char?)null;\n\t\tvar right = i < s.Length - 1 ? chars[i + 1] : (char?)null;\n\n\t\tif (left != \'a\' && right != \'a\') chars[...
10
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
EASY C++ solution with comments || O(n)
easy-c-solution-with-comments-on-by-sky9-sjgv
\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i = 0;i < s.size();i++){\n if(s[i] == \'?\'){\n \n
sky97
NORMAL
2020-09-06T04:04:21.383703+00:00
2020-09-06T04:04:21.383768+00:00
1,141
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i = 0;i < s.size();i++){\n if(s[i] == \'?\'){\n \n if(i == 0){ // if we are starting then we have to check only next character\n if(i + 1 < s.size()){\n ...
10
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
1576. Replace All ?'s to Avoid Consecutive Re..., Time Complexity: O(N), Space Complexity: O(1)
1576-replace-all-s-to-avoid-consecutive-5lyai
IntuitionApproachComplexity Time complexity: O(N) Space complexity: O(1) Code
richardmantikwang
NORMAL
2024-12-19T10:44:55.036685+00:00
2024-12-19T10:47:29.251629+00:00
141
false
# 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)$$ -->...
9
0
['Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
[Java] a, b, c solution beats 100% - comment explained
java-a-b-c-solution-beats-100-comment-ex-1xpc
\nclass Solution {\n public String modifyString(String s) {\n char[] ch = s.toCharArray();\n for (int i = 0;i<ch.length;i++){\n if (
vinsinin
NORMAL
2021-02-23T07:40:34.426814+00:00
2021-02-23T07:40:34.426850+00:00
1,070
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] ch = s.toCharArray();\n for (int i = 0;i<ch.length;i++){\n if (ch[i] == \'?\'){\n for (char j = \'a\'; j <= \'c\';j++){\n if (i > 0 && ch[i-1] == j) continue; //skip if previous characte...
9
1
['Java']
1
replace-all-s-to-avoid-consecutive-repeating-characters
python3 beginner friendly
python3-beginner-friendly-by-m0u1ea5-rrwr
python\nclass Solution:\n def modifyString(self, s: str) -> str:\n if len(s)==1:\n return \'a\' \n s=list(s)\n for i in range
M0u1ea5
NORMAL
2020-12-07T05:55:18.202491+00:00
2021-03-20T12:30:07.042145+00:00
937
false
```python\nclass Solution:\n def modifyString(self, s: str) -> str:\n if len(s)==1:\n return \'a\' \n s=list(s)\n for i in range(len(s)):\n if s[i] == \'?\':\n for x in \'abc\': \n if i == 0 and s[i+1] != x: \n ...
9
0
[]
2
replace-all-s-to-avoid-consecutive-repeating-characters
[C++] Simple Brute Force Solution | Self-Explanatory
c-simple-brute-force-solution-self-expla-c7gd
\nclass Solution\n{\npublic:\n string modifyString(string s)\n {\n char temp1, temp2;\n int index;\n for (int k = 0; k < s.length();
ravireddy07
NORMAL
2020-09-06T04:41:03.755820+00:00
2021-03-12T17:05:52.045818+00:00
836
false
```\nclass Solution\n{\npublic:\n string modifyString(string s)\n {\n char temp1, temp2;\n int index;\n for (int k = 0; k < s.length(); ++k)\n {\n if (s[k] == \'?\')\n {\n index = k;\n for (int i = 0; i < 26; ++i)\n {\n...
9
1
['C']
1
replace-all-s-to-avoid-consecutive-repeating-characters
💻✅BEATS 100%⌛⚡[C++/Java/Py3/JS]🍨| EASY n CLEAN EXPLANATION⭕💌
beats-100cjavapy3js-easy-n-clean-explana-blry
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
Fawz-Haaroon
NORMAL
2025-03-20T05:13:34.799380+00:00
2025-03-20T05:13:34.799380+00:00
60
false
# 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 ...
8
0
['String', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python 3 Solution for Beginners ( 3 letter soln)
python-3-solution-for-beginners-3-letter-geau
\nclass Solution:\n def modifyString(self, s: str) -> str:\n if len(s)==1: #if input contains only a \'?\'\n if s[0]==\'?\':\n
nikhilsmanu
NORMAL
2020-09-06T04:37:07.589668+00:00
2020-09-06T04:41:53.043467+00:00
1,448
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n if len(s)==1: #if input contains only a \'?\'\n if s[0]==\'?\':\n return \'a\'\n s=list(s)\n for i in range(len(s)):\n if s[i]==\'?\':\n for c in \'abc\':\n if ...
8
1
['Python', 'Python3']
1
replace-all-s-to-avoid-consecutive-repeating-characters
C++ O(n) 0ms solution
c-on-0ms-solution-by-ashshetty333-w2tq
\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i=0; i<s.size(); ++i)\n {\n if(s[i]==\'?\')\n {\n
ashshetty333
NORMAL
2020-09-09T09:54:45.986671+00:00
2020-09-09T09:54:45.986700+00:00
411
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i=0; i<s.size(); ++i)\n {\n if(s[i]==\'?\')\n {\n s[i]=\'a\';\n while((i>0 && s[i]==s[i-1]) || ((i+1)<s.size() && s[i]==s[i+1]))\n {\n s[i]++...
7
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python | Easy Solution✅
python-easy-solution-by-gmanayath-ettc
Code\u2705\n\nclass Solution:\n def modifyString(self, s: str) -> str:\n if s =="?":\n return "a"\n if len(s) == 1:\n ret
gmanayath
NORMAL
2023-02-03T07:50:55.772381+00:00
2023-02-03T07:50:55.772434+00:00
971
false
# Code\u2705\n```\nclass Solution:\n def modifyString(self, s: str) -> str:\n if s =="?":\n return "a"\n if len(s) == 1:\n return s\n \n s_list = [x for x in s]\n for index, letter in enumerate(s_list):\n replace_char = {"a","b","c"} \n ...
6
0
['String', 'Python', 'Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy to understand Java solution beats 100%
easy-to-understand-java-solution-beats-1-g9cw
\nclass Solution {\n public String modifyString(String s) {\n char[] S = s.toCharArray();\n for (int i = 0; i < S.length; i++) {\n i
endianless
NORMAL
2021-03-03T02:00:47.951507+00:00
2021-03-03T02:00:47.951564+00:00
427
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] S = s.toCharArray();\n for (int i = 0; i < S.length; i++) {\n if (S[i] != \'?\') continue;\n char prev = i > 0 ? S[i - 1] : (char) (\'a\' - 1);\n char next = i < S.length - 1 ? S[i + 1] : (char) (\'...
6
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
python solution
python-solution-by-akaghosting-ia2t
\tclass Solution:\n\t\tdef modifyString(self, s: str) -> str:\n\t\t\tif s == "?":\n\t\t\t\treturn "a"\n\t\t\tletters = "abcdefghijklmnopqrstuvwxyz"\n\t\t\tres =
akaghosting
NORMAL
2020-09-06T04:23:17.749337+00:00
2020-09-06T04:23:17.749392+00:00
555
false
\tclass Solution:\n\t\tdef modifyString(self, s: str) -> str:\n\t\t\tif s == "?":\n\t\t\t\treturn "a"\n\t\t\tletters = "abcdefghijklmnopqrstuvwxyz"\n\t\t\tres = ""\n\t\t\tfor i in range(len(s)):\n\t\t\t\tif s[i] != "?":\n\t\t\t\t\tres += s[i]\n\t\t\t\telse:\n\t\t\t\t\tif i == 0:\n\t\t\t\t\t\tfor j in letters:\n\t\t\t\t...
6
1
[]
2
replace-all-s-to-avoid-consecutive-repeating-characters
JavaScript
javascript-by-adrianlee0118-i2px
\nconst modifyString = s => {\n for (let i = 0; i < s.length; i++){ //Iterating through the string\n if (s[i] === \'?\'){
adrianlee0118
NORMAL
2020-09-06T04:00:26.517857+00:00
2020-09-06T04:00:26.517903+00:00
441
false
```\nconst modifyString = s => {\n for (let i = 0; i < s.length; i++){ //Iterating through the string\n if (s[i] === \'?\'){ //If a \'?\' is encountered\n let rep = \'\';\n if (s[i-1] !== \'a\' && s[i+1] !== \'a\') rep = \'a\'; //determine the...
6
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
JAVA | Easy solution ✅
java-easy-solution-by-sourin_bruh-6pj7
Please Upvote :D\njava []\nclass Solution {\n public String modifyString(String s) {\n if (s.equals("?")) { // edge case\n return "a";\n
sourin_bruh
NORMAL
2023-01-22T18:06:21.683340+00:00
2023-01-22T18:11:08.080962+00:00
937
false
# 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 // corne...
4
0
['String', 'Java']
1
replace-all-s-to-avoid-consecutive-repeating-characters
Simple Python solution
simple-python-solution-by-c_n-ci88
Idea:\nFor every ? in the string, recplace it with either a, b, or c, as there are only two sides for \neach letter therefor there is no need for other letters
C_N_
NORMAL
2021-11-05T11:30:01.287339+00:00
2021-11-29T21:19:39.308719+00:00
458
false
**Idea:**\nFor every `?` in the string, recplace it with either `a, b, or c`, as there are only two sides for \neach letter therefor there is no need for other letters in the alphabet to recplace it in order to receive a valid string.\n(The spaces added to the beginning and end of the string are in order to skip checki...
4
0
['Python3']
2
replace-all-s-to-avoid-consecutive-repeating-characters
EASY JAVA CODE
easy-java-code-by-190030664-peiy
\nclass Solution {\n public String modifyString(String s) {\n char c;\n char[] chars = s.toCharArray();\n for (int i=0; i<s.length(); i+
190030664
NORMAL
2021-03-13T05:10:07.012015+00:00
2021-03-13T05:10:07.012052+00:00
675
false
```\nclass Solution {\n public String modifyString(String s) {\n char c;\n char[] chars = s.toCharArray();\n for (int i=0; i<s.length(); i++){\n if(chars[i] == \'?\'){\n for(c=\'a\'; c<=\'z\'; c++){\n if((i == 0 || c != chars[i-1]) && (i == s.length()...
4
0
['String', 'Java']
1
replace-all-s-to-avoid-consecutive-repeating-characters
simple and easy C++ solution 😍❤️‍🔥
simple-and-easy-c-solution-by-shishirrsi-uxt1
if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n\nclass Solution {\npublic:\n bool isValidIndex(int i, int n)\n {\n return (i >= 0
shishirRsiam
NORMAL
2024-06-14T15:20:51.096025+00:00
2024-06-14T15:20:51.096058+00:00
273
false
# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n\n# Code\n```\nclass Solution {\npublic:\n bool isValidIndex(int i, int n)\n {\n return (i >= 0 and i < n);\n }\n string modifyString(string s) \n {\n int n = s.size();\n if(n == 1 and s[0] == \'?\') return "a";\n for(int...
3
0
['String', 'Simulation', 'C++']
3
replace-all-s-to-avoid-consecutive-repeating-characters
Python random choice solution
python-random-choice-solution-by-inversi-z2xh
Intuition\n Describe your first thoughts on how to solve this problem. \nI came up with this random choice solution. \nHowever, I realized that we only need thr
inversion39
NORMAL
2022-12-20T03:55:53.017538+00:00
2022-12-20T03:55:53.017578+00:00
665
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI came up with this random choice solution. \nHowever, I realized that we only need three letters when I checked out the other solutions. LOL\nAnyway, the upper lengh of the string is 100. \nSo I guess there is no big difference in time c...
3
0
['Python3']
1
replace-all-s-to-avoid-consecutive-repeating-characters
javaScript, Simple Solution
javascript-simple-solution-by-petr12332-4q2p
var modifyString = function (s) {\n let arr = s.split("");\n for (let i = 0; i <= arr.length; i++) {\n let res = ["a", "b", "c"];\n if (arr[i] === "?")
Petr12332
NORMAL
2022-12-05T12:01:11.085837+00:00
2022-12-05T13:21:47.986569+00:00
680
false
var modifyString = function (s) {\n let arr = s.split("");\n for (let i = 0; i <= arr.length; i++) {\n let res = ["a", "b", "c"];\n if (arr[i] === "?") {\n if (arr[i - 1] === "a" || arr[i + 1] === "a") {\n res.splice(res.indexOf("a"), 1);\n }\n if (arr[i - 1] === "b" || arr[i + 1] === "b")...
3
0
['JavaScript']
0
replace-all-s-to-avoid-consecutive-repeating-characters
JavaScript Simple Solution (Faster than 99.4%)
javascript-simple-solution-faster-than-9-3vx0
javascript\nconst modifyString = function(s) {\n let res = [...s];\n \n for (let i = 0; i < res.length; i++) {\n if (res[i] !== "?") continue;\n if (re
Cookie_Ryu
NORMAL
2021-07-21T14:21:17.187636+00:00
2021-07-21T14:21:17.187673+00:00
304
false
```javascript\nconst modifyString = function(s) {\n let res = [...s];\n \n for (let i = 0; i < res.length; i++) {\n if (res[i] !== "?") continue;\n if (res[i-1] !== "a" && res[i+1] !== "a") { res[i] = "a"; continue; }\n if (res[i-1] !== "b" && res[i+1] !== "b") { res[i] = "b"; continue; }\n res[i] = "c";...
3
0
['JavaScript']
1
replace-all-s-to-avoid-consecutive-repeating-characters
As easy as "abc"
as-easy-as-abc-by-ecgan-x5w4
js\nconst convertChar = (arr, i) => {\n if (arr[i] !== \'?\') {\n return arr[i]\n }\n\n if (arr[i - 1] !== \'a\' && arr[i + 1] !== \'a\') {\n return \'
ecgan
NORMAL
2020-09-06T09:05:29.143489+00:00
2020-09-06T09:07:44.805888+00:00
449
false
```js\nconst convertChar = (arr, i) => {\n if (arr[i] !== \'?\') {\n return arr[i]\n }\n\n if (arr[i - 1] !== \'a\' && arr[i + 1] !== \'a\') {\n return \'a\'\n }\n\n if (arr[i - 1] !== \'b\' && arr[i + 1] !== \'b\') {\n return \'b\'\n }\n\n return \'c\'\n}\n\n/**\n * @param {string} s\n * @return {strin...
3
0
['JavaScript']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Simple Python, We just need 3 characters('a', 'b', 'c')
simple-python-we-just-need-3-charactersa-029y
Okay so the idea is basically, we dont want any 2 characters to be consecutive, so all we have to make sure that: if both the adjacent characters are not \'a\',
shubhitt
NORMAL
2020-09-06T04:06:14.668803+00:00
2020-09-06T04:06:14.668905+00:00
247
false
Okay so the idea is basically, we dont want any 2 characters to be consecutive, so all we have to make sure that: if both the adjacent characters are not \'a\', we can replace \'?\' by \'a\'\nsimilarly with \'b\' and \'c\'\n\n```\nclass Solution:\n def modifyString(self, s: str) -> str:\n s = \'1\' + s + \'1\...
3
1
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Very simple & easy to understand.
very-simple-easy-to-understand-by-srh_ab-cf72
\n# Code\npython3 []\nclass Solution:\n def modifyString(self, s: str) -> str:\n # Convert the string to a list of characters since strings are immuta
srh_abhay
NORMAL
2024-11-18T02:52:18.266817+00:00
2024-11-18T02:52:47.874760+00:00
98
false
\n# Code\n```python3 []\nclass Solution:\n def modifyString(self, s: str) -> str:\n # Convert the string to a list of characters since strings are immutable\n s = list(s)\n \n # Helper function to get a valid character for replacement\n def get_valid_char(i):\n # We need...
2
0
['Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python Easy Solution
python-easy-solution-by-sumedh0706-b1nu
Code\n\nclass Solution:\n def modifyString(self, s: str) -> str:\n new=s\n for i in range(len(s)):\n if new[i]=="?":\n
Sumedh0706
NORMAL
2023-06-30T10:41:47.010466+00:00
2023-06-30T10:41:47.010494+00:00
189
false
# Code\n```\nclass Solution:\n def modifyString(self, s: str) -> str:\n new=s\n for i in range(len(s)):\n if new[i]=="?":\n if len(new)==1:\n return "p"\n if i==0:\n lis=[new[i+1]]\n if i==len(s)-1:\n ...
2
0
['Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
CPP || EASY || 3ms
cpp-easy-3ms-by-peeronappper-2iuo
\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i=0;i<s.length();i++){\n if(i==0 && s[i]==\'?\') s[i]=(s[i+1]+1)%26
PeeroNappper
NORMAL
2022-06-13T11:08:09.207677+00:00
2022-06-13T11:08:09.207717+00:00
235
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n for(int i=0;i<s.length();i++){\n if(i==0 && s[i]==\'?\') s[i]=(s[i+1]+1)%26+\'a\';\n else if(i==s.length()-1 && s[i]==\'?\') s[i]=(s[i-1]-\'a\'+1)%26+\'a\';\n else if(s[i]==\'?\'){\n int p=1;\n ...
2
0
['C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Golang Simple O(n)
golang-simple-on-by-alfinm01-aerq
\nfunc modifyString(s string) string {\n str := strings.Split(s, "")\n chars := []string{"a", "b", "c"}\n\t\n for i := range str {\n if str[i] !
alfinm01
NORMAL
2021-11-08T02:39:45.218523+00:00
2022-07-25T09:50:06.891231+00:00
147
false
```\nfunc modifyString(s string) string {\n str := strings.Split(s, "")\n chars := []string{"a", "b", "c"}\n\t\n for i := range str {\n if str[i] != "?" {\n\t\t\tcontinue\n\t\t}\n\t\t\n\t\tfor _, c := range chars {\n\t\t\tif (i == 0 || str[i-1] != c) && (i == len(s)-1 || str[i+1] != c) {\n\t\t\t\tstr[i]...
2
0
['Go']
0
replace-all-s-to-avoid-consecutive-repeating-characters
[Python3] Faster than 90% submissions, simple code
python3-faster-than-90-submissions-simpl-wxg5
Execution Result\n\n\nRuntime: 28 ms, faster than 90.93% of Python3 online submissions for Replace All ?\'s to Avoid Consecutive Repeating Characters.\nMemory U
GauravKK08
NORMAL
2021-07-05T14:49:52.039789+00:00
2021-07-05T14:50:51.529125+00:00
155
false
`Execution Result`\n\n```\nRuntime: 28 ms, faster than 90.93% of Python3 online submissions for Replace All ?\'s to Avoid Consecutive Repeating Characters.\nMemory Usage: 14.1 MB, less than 92.19% of Python3 online submissions for Replace All ?\'s to Avoid Consecutive Repeating Characters.\n```\n\n`Solution`\n```\nclas...
2
0
['Python3']
1
replace-all-s-to-avoid-consecutive-repeating-characters
C++ 100% Faster
c-100-faster-by-ayush_gupta4-k3gy
\nclass Solution {\npublic:\n string modifyString(string s) {\n int i,n=s.size();\n for(i=0;i<n;i++){\n if(s[i]==\'?\'){\n
ayush_gupta4
NORMAL
2021-06-05T08:49:05.138769+00:00
2021-06-05T08:49:05.138801+00:00
97
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n int i,n=s.size();\n for(i=0;i<n;i++){\n if(s[i]==\'?\'){\n s[i]=\'a\';\n while((i>0 && s[i]==s[i-1]) || (i+1<n && s[i]==s[i+1])) s[i]++;\n }\n }\n return s;\n }\n};\n`...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Javascript easy to read
javascript-easy-to-read-by-fbecker11-2low
\nvar modifyString = function(s) {\n const arr = s.split(\'\')\n let res = \'\'\n for(let i=0;i<s.length;i++){\n const curr = arr[i]\n if(curr !== \'?\
fbecker11
NORMAL
2021-05-01T14:40:17.607185+00:00
2021-05-01T14:41:22.811547+00:00
231
false
```\nvar modifyString = function(s) {\n const arr = s.split(\'\')\n let res = \'\'\n for(let i=0;i<s.length;i++){\n const curr = arr[i]\n if(curr !== \'?\') continue\n const prevCharCode = (arr[i-1] || \'\').charCodeAt(0)\n const nextCharCode = (arr[i+1] || \'\').charCodeAt(0)\n let random = 0\n wh...
2
0
['JavaScript']
0
replace-all-s-to-avoid-consecutive-repeating-characters
C# solution
c-solution-by-daraa-3h4j
\nStringBuilder sb = new StringBuilder();\n sb.Append(s);\n for(int i=0;i<sb.Length;i++){\n if(s[i]==\'?\'){\n for(char
daraa
NORMAL
2021-04-24T10:29:58.930272+00:00
2021-04-24T10:29:58.930303+00:00
89
false
```\nStringBuilder sb = new StringBuilder();\n sb.Append(s);\n for(int i=0;i<sb.Length;i++){\n if(s[i]==\'?\'){\n for(char j=\'a\'; j<=\'z\';j++){\n if(i-1>=0 && j == sb[i-1]) continue;\n if(i+1<sb.Length && j == sb[i+1]) continue;\n ...
2
0
['String']
0
replace-all-s-to-avoid-consecutive-repeating-characters
C++ 0ms
c-0ms-by-leetweeb-mh3o
```\nclass Solution {\npublic:\n string modifyString(string s) {\n int n = s.size();\n for(int i=0;i=0)\n prev = s[i-1];\n
LeetWeeb
NORMAL
2021-04-13T08:37:25.220937+00:00
2021-04-13T08:37:25.220977+00:00
69
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n int n = s.size();\n for(int i=0;i<n;i++)\n {\n if(s[i] == \'?\')\n {\n char c = \'a\';\n char prev = \'a\',next = \'a\';\n if(i-1 >=0)\n prev =...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
easy to understand java
easy-to-understand-java-by-d_eat_h-teko
```\nclass Solution {\n public String modifyString(String s) {\n char[] arr = s.toCharArray();\n for(int i = 0; i < arr.length; i++){\n
D_eat_H
NORMAL
2021-04-11T01:34:36.816454+00:00
2021-04-11T01:34:36.816493+00:00
79
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] arr = s.toCharArray();\n for(int i = 0; i < arr.length; i++){\n if(s.charAt(i) != \'?\')\n continue;\n for(char ch = \'a\'; ch <= \'z\'; ch++){\n if(satisfies(arr, ch, i)){\n ...
2
1
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
C# straightforward solution 76ms
c-straightforward-solution-76ms-by-iiii1-uhgl
\npublic class Solution {\n public string ModifyString(string s) {\n char[] letters = new char[]{\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\'
iiii110270
NORMAL
2021-03-25T06:07:53.751056+00:00
2021-03-25T06:07:53.751089+00:00
69
false
```\npublic class Solution {\n public string ModifyString(string s) {\n char[] letters = new char[]{\'a\',\'b\',\'c\',\'d\',\'e\',\'f\',\'g\',\'h\',\'i\',\n \'j\',\'k\',\'l\',\'m\',\'n\',\'o\',\'p\',\'q\',\'r\',\n \'s\',\'t\',\'u\',\'v\',\'...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
c++ simple solution (0ms)
c-simple-solution-0ms-by-dilipsuthar60-umh1
\nclass Solution {\npublic:\n string modifyString(string s) \n {\n int n=s.size();\n for(int i=0;i<n;i++)\n {\n if(s[i]==\
dilipsuthar17
NORMAL
2021-02-04T15:48:48.810259+00:00
2021-02-04T15:48:48.810310+00:00
112
false
```\nclass Solution {\npublic:\n string modifyString(string s) \n {\n int n=s.size();\n for(int i=0;i<n;i++)\n {\n if(s[i]==\'?\')\n {\n s[i]=\'a\';\n while(((i>0)&&(s[i-1]==s[i]))||(i+1<n&&(s[i+1]==s[i])))\n {\n ...
2
0
[]
2
replace-all-s-to-avoid-consecutive-repeating-characters
Java Straightforward Solution
java-straightforward-solution-by-ensifer-36u8
\nclass Solution {\n public String modifyString(String s) {\n char[] res = s.toCharArray();\n for(int i = 0; i < res.length; i++) {\n
ensiferum
NORMAL
2021-01-30T19:53:00.086126+00:00
2021-01-31T00:39:32.631544+00:00
177
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] res = s.toCharArray();\n for(int i = 0; i < res.length; i++) {\n char c = res[i];\n if(c == \'?\') {\n char repl = \'a\';\n while((i > 0 && res[i - 1] == repl)\n ...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
simple solution - python
simple-solution-python-by-waveletus-jvpy
\nclass Solution:\n def modifyString(self, s: str) -> str:\n res = list(s)\n \n for i in range(len(res)):\n if res[i] == \'?\
waveletus
NORMAL
2020-11-23T04:01:42.448679+00:00
2020-11-23T04:01:42.448705+00:00
155
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n res = list(s)\n \n for i in range(len(res)):\n if res[i] == \'?\':\n left = res[i-1] if i > 0 else \'\'\n right = res[i+1] if i < len(s) - 1 else \'\'\n \n for c...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python solution faster than 100 percent!
python-solution-faster-than-100-percent-2clfn
\nclass Solution:\n def modifyString(self, s: str) -> str:\n ans=\'\'\n if len(s)==1:\n if s[0]==\'?\':\n return \'a\
man_it
NORMAL
2020-09-07T10:28:57.130515+00:00
2020-09-07T10:28:57.130569+00:00
628
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n ans=\'\'\n if len(s)==1:\n if s[0]==\'?\':\n return \'a\'\n else:\n return s\n \n if s[0]=="?":\n for j in range(97,124):\n if ord(s[1])!=j:\n ...
2
0
['Python', 'Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
C++ O(N) One Pass with explanation
c-on-one-pass-with-explanation-by-lzl124-w73e
See my latest update in repo LeetCode\n\n## Solution 1.\n\nWhen we see a s[i] == \'?\', we set it as s[i - 1] + 1 and round it to \'a\' if necessary.\n\nWhen s[
lzl124631x
NORMAL
2020-09-06T04:08:40.041625+00:00
2020-09-06T04:11:55.882085+00:00
187
false
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nWhen we see a `s[i] == \'?\'`, we set it as `s[i - 1] + 1` and round it to `\'a\'` if necessary.\n\nWhen `s[i] == \'?\' && s[i + 1] != \'?\'`, there is a chance of conflict with `s[i + 1]`. If there is a conflict, we si...
2
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
100% beats in c++ solution.
100-beats-in-c-solution-by-jahidulcse15-80im
IntuitionApproachComplexity Time complexity:O(N) Space complexity:O(N) Code
jahidulcse15
NORMAL
2025-04-12T05:50:24.091296+00:00
2025-04-12T05:50:24.091296+00:00
1
false
# 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(N) <!-- Add your space complexity here, e.g. $$O(n)$$ --> ...
1
0
['C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
<<BEAT 100% SOLUTIONS>>
beat-100-solutions-by-dakshesh_vyas123-09mu
PLEASE UPVOTE MECode
Dakshesh_vyas123
NORMAL
2025-03-18T16:41:35.442207+00:00
2025-03-18T16:41:35.442207+00:00
21
false
# PLEASE UPVOTE ME # Code ```cpp [] class Solution { public: string modifyString(string s) { for (auto i = 0; i < s.size(); ++i) if (s[i] == '?') for (s[i] = 'a'; s[i] <= 'c'; ++s[i]) if ((i == 0 || s[i - 1] != s[i]) && (i == s.size() - 1 || s[i + 1] != s[i])) ...
1
0
['C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy Solution for beginners || Beats 100%+✨ || ✌️🥱
easy-solution-for-beginners-beats-100-by-0at5
\n# Approach:\n Describe your approach to solving the problem. \nTo solve this, we turn the string into a list to easily change its characters. As we go through
07_deepak
NORMAL
2024-10-22T12:44:42.643009+00:00
2024-10-22T12:45:29.805009+00:00
16
false
\n# Approach:\n<!-- Describe your approach to solving the problem. -->\n*To solve this, we turn the string into a list to easily change its characters. As we go through the string, we replace each `\'?\'` with a letter, making sure it\u2019s different from its neighbors. For the first and last characters, we only check...
1
1
['Python', 'Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy C++ Solution
easy-c-solution-by-bharijamegha-tu5g
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
bharijamegha
NORMAL
2024-10-05T11:05:06.013768+00:00
2024-10-05T11:05:06.013796+00:00
56
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
1
replace-all-s-to-avoid-consecutive-repeating-characters
abba accepted !!! Ganapati Bappa Morya ,Mangal Murthi Morya !!!!! :D
abba-accepted-ganapati-bappa-morya-manga-qatf
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
yesyesem
NORMAL
2024-09-06T18:59:06.257258+00:00
2024-09-06T18:59:06.257284+00:00
33
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Dart Solution
dart-solution-by-abbos2101-c0i8
\nclass Solution {\n String modifyString(String s) {\n final letters = List.generate(26, (i) => String.fromCharCode(i + 97));\n int index = s.indexOf(\'?
abbos2101
NORMAL
2024-07-10T22:10:47.249780+00:00
2024-07-10T22:10:47.249808+00:00
4
false
```\nclass Solution {\n String modifyString(String s) {\n final letters = List.generate(26, (i) => String.fromCharCode(i + 97));\n int index = s.indexOf(\'?\');\n while (index != -1) {\n String first = \'\';\n String second = \'\';\n if (index > 0) first = s[index - 1];\n if (index < s.len...
1
0
['Dart']
0
replace-all-s-to-avoid-consecutive-repeating-characters
[Python] ugly code
python-ugly-code-by-pbelskiy-09t9
\nclass Solution:\n def modifyString(self, s: str) -> str:\n a = list(s)\n\n for i in range(len(a)):\n if a[i] != \'?\':\n
pbelskiy
NORMAL
2024-05-16T07:27:53.173020+00:00
2024-05-16T07:27:53.173052+00:00
14
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n a = list(s)\n\n for i in range(len(a)):\n if a[i] != \'?\':\n continue\n\n used = set()\n if i > 0:\n used.add(a[i - 1])\n if i + 1 < len(s):\n used.a...
1
0
['Python']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Simple java code 1 ms beats 100 % && 42 mb beats 88.78 %
simple-java-code-1-ms-beats-100-42-mb-be-rhyc
\n# Complexity\n\n- image.png\n# Code\n\nclass Solution {\n public char help(char p,char n){\n for(char c=\'b\';c<=\'y\';c++){\n if(c!=p&&c
Arobh
NORMAL
2024-03-25T06:23:22.040499+00:00
2024-03-25T06:23:22.040518+00:00
268
false
\n# Complexity\n![image.png](https://assets.leetcode.com/users/images/f383333f-b9b0-4ce5-a4f4-68239d004394_1711347757.5247393.png)\n- image.png\n# Code\n```\nclass Solution {\n public char help(char p,char n){\n for(char c=\'b\';c<=\'y\';c++){\n if(c!=p&&c!=n) return c;\n }\n return ...
1
0
['String', 'Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy to understand solution
easy-to-understand-solution-by-pratik_pa-eghl
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Pratik_Pathak_05
NORMAL
2024-02-10T15:57:38.438396+00:00
2024-02-10T15:57:38.438424+00:00
14
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
1
0
['Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy / Simple [ C | C++ | Java ] -- Dry Run Beats 100% in runtime & memory..
easy-simple-c-c-java-dry-run-beats-100-i-kovd
Intuition\n\nC++ []\nclass Solution {\npublic:\n string modifyString(string s) {\n for (auto i = 0; i < s.size(); ++i)\n if (s[i] == \'?\')
Edwards310
NORMAL
2024-02-04T08:04:17.850195+00:00
2024-02-04T08:04:17.850219+00:00
26
false
# Intuition\n![Screenshot 2024-02-04 132949.png](https://assets.leetcode.com/users/images/c33ca3f9-fed2-4863-9706-b8807efa51ad_1707033617.7761476.png)\n```C++ []\nclass Solution {\npublic:\n string modifyString(string s) {\n for (auto i = 0; i < s.size(); ++i)\n if (s[i] == \'?\')\n ...
1
0
['String', 'C', 'C++', 'Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
JS || Soution by Bharadwaj
js-soution-by-bharadwaj-by-manu-bharadwa-r401
Intuition\nfunction modifyString(s) {\n // Array of lowercase letters for replacement\n const letters = [\'a\', \'b\', ..., \'z\'];\n\n // Iterate through ea
Manu-Bharadwaj-BN
NORMAL
2024-01-11T06:39:17.647960+00:00
2024-01-11T06:39:17.647982+00:00
51
false
# Intuition\nfunction modifyString(s) {\n // Array of lowercase letters for replacement\n const letters = [\'a\', \'b\', ..., \'z\'];\n\n // Iterate through each character in the string\n for (let i = 0; i < s.length; i++) {\n // If the character is \'?\', replace it with a distinct letter\n if (s[i] === \'?\...
1
0
['JavaScript']
1
replace-all-s-to-avoid-consecutive-repeating-characters
beats 100% cpp soln
beats-100-cpp-soln-by-vermasachin6101-5ees
Intuition\nIf the input string has length 1 and the only character is \'?\', it replaces it with \'a\'. Otherwise, it returns the original string.\n\nIf the fir
gyuyul
NORMAL
2023-12-20T15:08:55.262963+00:00
2023-12-20T15:08:55.262986+00:00
12
false
# Intuition\nIf the input string has length 1 and the only character is \'?\', it replaces it with \'a\'. Otherwise, it returns the original string.\n\nIf the first character of the string is \'?\', it replaces it with \'a\' if the next character is \'a\', and with \'b\' otherwise.\n\nFor each \'?\' in the middle of th...
1
0
['C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy Solution for beginners || Beats 95%+✨💫 || 🧛✌️
easy-solution-for-beginners-beats-95-by-ech8m
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
EraOfKaushik003
NORMAL
2023-07-23T09:00:07.826303+00:00
2023-07-23T09:02:12.042393+00:00
453
false
# 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 stri...
1
0
['String', 'Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy, Simple and Fastest way in C++
easy-simple-and-fastest-way-in-c-by-ashu-3ncx
Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n string modifyString(string s) {\n int len =
ashujain
NORMAL
2023-06-25T04:03:21.986686+00:00
2023-06-25T04:03:21.986705+00:00
113
false
# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n string modifyString(string s) {\n int len = s.size();\n for(int i=0; i<s.size(); i++) {\n char c1, c2;\n if(s[i] == \'?\') {\n if(i-1>=0 && i+1<len) {\n ...
1
0
['C++']
1
replace-all-s-to-avoid-consecutive-repeating-characters
Java O(n) | 100%
java-on-100-by-im_obid-3k2e
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
im_obid
NORMAL
2023-05-16T04:07:53.139485+00:00
2023-05-16T04:08:24.736906+00:00
64
false
**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[...
1
0
['Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
c++ simple solution 100% beats in 0ms.
c-simple-solution-100-beats-in-0ms-by-co-5e9e
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1- iterate over the str
code_breaker_42
NORMAL
2023-05-05T14:04:37.901933+00:00
2023-05-05T14:04:37.901970+00:00
598
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1- iterate over the string.\n2-than make a function of default arguments to handle multiple cases in one function.\n3-function contain a for loop fron a to z.\n4-if(i ...
1
0
['C++']
1
replace-all-s-to-avoid-consecutive-repeating-characters
Replace All ?'s to Avoid Consecutive Repeating Characters Solution Java
replace-all-s-to-avoid-consecutive-repea-iv7t
class Solution {\n public String modifyString(String s) {\n char[] array = s.toCharArray();\n int length = array.length;\n if (array[0]
bhupendra786
NORMAL
2022-09-15T08:13:33.973164+00:00
2022-09-15T08:13:33.973204+00:00
310
false
class Solution {\n public String modifyString(String s) {\n char[] array = s.toCharArray();\n int length = array.length;\n if (array[0] == \'?\') {\n if (length == 1)\n array[0] = \'a\';\n else {\n if (array[1] == \'a\')\n ar...
1
0
['String']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python, less condition approach
python-less-condition-approach-by-maleki-r72o
\nclass Solution:\n def modifyString(self, s: str) -> str:\n s = list("0"+s+"0")\n for i, l in enumerate(s[:-1]):\n if l == "?":\n
maleki_shoja
NORMAL
2022-08-30T15:38:20.328515+00:00
2022-08-30T15:38:20.328556+00:00
396
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n s = list("0"+s+"0")\n for i, l in enumerate(s[:-1]):\n if l == "?":\n for c in "abc":\n if c != s[i-1] and c != s[i+1]:\n s[i] = c\n break\n ...
1
0
['Python']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Java Solution | Runtime: 2ms
java-solution-runtime-2ms-by-harsh_kode-quiu
\nclass Solution {\n public String modifyString(String s) {\n char[] ch = s.toCharArray();\n for(int i=0;i<s.length();i++){\n if(ch[
Harsh_Kode
NORMAL
2022-08-26T20:18:29.304291+00:00
2022-08-26T20:18:29.304361+00:00
443
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] ch = s.toCharArray();\n for(int i=0;i<s.length();i++){\n if(ch[i]==\'?\')\n for(char j=\'a\';j<=\'c\';j++){ // j = (a-z) is not required.\n if(i>0 && ch[i-1]==j) continue; // skip if pre...
1
0
['String', 'Java']
1
replace-all-s-to-avoid-consecutive-repeating-characters
[C++] || Very easy to understand
c-very-easy-to-understand-by-riteshkhan-nfwh
\nclass Solution {\n char update_char(char x, char y){\n char c = \'a\';\n while(c==x || c==y){\n c++;\n }\n return c;
RiteshKhan
NORMAL
2022-07-25T08:43:33.594589+00:00
2022-07-25T08:53:38.819054+00:00
215
false
```\nclass Solution {\n char update_char(char x, char y){\n char c = \'a\';\n while(c==x || c==y){\n c++;\n }\n return c;\n }\npublic:\n string modifyString(string s) {\n int l = s.length();\n char c;\n if(s[0] == \'?\'){\n c = update_char(...
1
0
['C']
0
replace-all-s-to-avoid-consecutive-repeating-characters
🐌 C# - straightforward solution
c-straightforward-solution-by-user7166uf-3gr3
\npublic class Solution\n{\n public string ModifyString(string s)\n {\n char[] characters = s.ToCharArray();\n\n for (int index = 0; index <
user7166Uf
NORMAL
2022-06-12T12:39:50.011930+00:00
2022-06-12T12:39:50.011970+00:00
62
false
```\npublic class Solution\n{\n public string ModifyString(string s)\n {\n char[] characters = s.ToCharArray();\n\n for (int index = 0; index < characters.Length; index++)\n {\n if (characters[index] is not \'?\') continue;\n\n char? previousCharacter = index > 0 ? chara...
1
0
['C#']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Tried a lot but only 749/776 passed :(
tried-a-lot-but-only-749776-passed-by-ch-jcpg
\nclass Solution {\npublic:\n string modifyString(string s) {\n string str="";\n for(int i=0;i<s.size();i++){\n if(s[i]==\'?\')\n
charu794
NORMAL
2022-05-07T11:01:59.222831+00:00
2022-05-07T11:01:59.222868+00:00
47
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n string str="";\n for(int i=0;i<s.size();i++){\n if(s[i]==\'?\')\n {\n int x,y;\n if(i==0){\n x= s[i+1];\n if(x<97 || x>122)\n ...
1
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
C++ solution
c-solution-by-charu794-ia25
\nclass Solution {\npublic:\n string modifyString(string s) {\n \n for(int i=0;i<s.size();i++)\n {\n if(s[i]==\'?\')\n
charu794
NORMAL
2022-05-07T11:00:31.805600+00:00
2022-05-07T11:00:31.805626+00:00
87
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n \n for(int i=0;i<s.size();i++)\n {\n if(s[i]==\'?\')\n {\n for(char ch=\'a\';ch<=\'z\';ch++)\n {\n if(i==0 && s[i+1]!=ch)\n {\n ...
1
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
java || easy to understand
java-easy-to-understand-by-pratham_18-zos6
\nclass Solution {\n public String modifyString(String s) {\n char arr[]=new char[s.length()];\n for(int i=0;i<s.length();i++){\n arr
Pratham_18
NORMAL
2022-04-19T07:38:21.417311+00:00
2022-04-19T07:38:21.417354+00:00
171
false
```\nclass Solution {\n public String modifyString(String s) {\n char arr[]=new char[s.length()];\n for(int i=0;i<s.length();i++){\n arr[i]=s.charAt(i);\n }\n for(int i=0;i<arr.length;i++){\n if(arr[i]==\'?\'){\n for(char j=\'a\';j<=\'c\';j++){\n ...
1
0
['Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
python clear and fast solution
python-clear-and-fast-solution-by-tirtha-xcdx
\n````\nclass Solution:\n def modifyString(self, s: str) -> str:\n a=list(s)+["."]\n for i in range(len(a)-1):\n if a[i]=="?":\n
tirtha_20
NORMAL
2022-03-11T12:10:00.096226+00:00
2022-03-11T12:10:00.096273+00:00
77
false
![image](https://assets.leetcode.com/users/images/66b5c536-5df1-4b41-88bb-5b2586e537ce_1646999808.040217.png)\n````\nclass Solution:\n def modifyString(self, s: str) -> str:\n a=list(s)+["."]\n for i in range(len(a)-1):\n if a[i]=="?":\n if a[i+1]!="a" and a[i-1]!="a":\n ...
1
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
2 C++ Solutions || Different Methods each time for replacement of '?' || Most Optimized Approach
2-c-solutions-different-methods-each-tim-fvbt
Approach 1\nIn this approach when we encounter a \'?\' we try from the first character \'a\', if the character satisfies the condition of the question i.e. not
dee_stroyer
NORMAL
2021-12-18T12:50:22.873634+00:00
2021-12-18T12:50:22.873675+00:00
172
false
**Approach 1**\nIn this approach when we encounter a \'?\' we try from the first character \'a\', if the character satisfies the condition of the question i.e. not similar to the consecutive one, then we replace the ? with the character, otherwise we increment the current char try doing the same as we did with a.\n```\...
1
0
['C', 'C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
C++ Simple and Short Straight-Forward Solution
c-simple-and-short-straight-forward-solu-0ier
Idea:\nWe only need three characters for replacement, because there can\'t be more than one character at each side of the ?.\nSo we try each letter and replace.
yehudisk
NORMAL
2021-11-03T22:30:20.622478+00:00
2021-11-03T22:30:20.622509+00:00
182
false
**Idea:**\nWe only need three characters for replacement, because there can\'t be more than one character at each side of the `?`.\nSo we try each letter and replace.\n\n**Time Complexity:** O(n)\n**Space Complexity:** None\n```\nclass Solution {\npublic:\n string modifyString(string s) {\n for (int i = 0; i ...
1
0
['C']
1
replace-all-s-to-avoid-consecutive-repeating-characters
Java- Easy Solution
java-easy-solution-by-srajen488-k4s0
\nclass Solution {\n public String modifyString(String s) {\n char[] str = s.toCharArray();\n for(int i =0; i < str.length; i ++)\n {\n
srajen488
NORMAL
2021-09-07T02:32:40.935085+00:00
2021-09-07T02:32:40.935122+00:00
170
false
```\nclass Solution {\n public String modifyString(String s) {\n char[] str = s.toCharArray();\n for(int i =0; i < str.length; i ++)\n {\n if(str[i] == \'?\')\n {\n str[i] = replaceChar(str, i);\n }\n }\n return String.valueOf(str);\n...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python Easy Solution - 90+% Faster
python-easy-solution-90-faster-by-gsbc95-yc96
\nclass Solution:\n def modifyString(self, s: str) -> str:\n prev = \'\'\n for index,value in enumerate(s):\n if value == \'?\':\n
gsbc95
NORMAL
2021-08-19T20:36:43.063699+00:00
2021-08-19T20:39:15.357553+00:00
109
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n prev = \'\'\n for index,value in enumerate(s):\n if value == \'?\':\n if index+1 < len(s):\n for i in range(97,123):\n if chr(i) !=s[index+1] and chr(i) != prev:\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python3, fast and simple
python3-fast-and-simple-by-mihailp-uh9r
\nclass Solution:\n def modifyString(self, s: str) -> str:\n ans = []\n\n for i, ch in enumerate(s):\n if ch != "?":\n
MihailP
NORMAL
2021-07-29T16:12:15.705703+00:00
2021-07-29T16:12:15.705754+00:00
303
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n ans = []\n\n for i, ch in enumerate(s):\n if ch != "?":\n ans.append(ch)\n else:\n prev_ch = ans[-1] if i > 0 else ""\n next_ch = s[i + 1] if i < len(s) - 1 else ""\n ...
1
1
['Python', 'Python3']
0
replace-all-s-to-avoid-consecutive-repeating-characters
simple C++
simple-c-by-rap_tors-j1hx
\nstring modifyString(string s) {\n for(int i = 0; i < s.size(); i++) {\n if(s[i] == \'?\') {\n for(char ch = \'a\'; ch <= \'c\
rap_tors
NORMAL
2021-07-04T17:22:28.492226+00:00
2021-07-04T17:22:28.492268+00:00
169
false
```\nstring modifyString(string s) {\n for(int i = 0; i < s.size(); i++) {\n if(s[i] == \'?\') {\n for(char ch = \'a\'; ch <= \'c\'; ch++) {\n if(i > 0 and s[i-1] == ch) continue;\n if(i < s.size() - 1 and s[i + 1] == ch) continue;\n ...
1
0
['C', 'C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Easy to understand JavaScript solution (reduce)
easy-to-understand-javascript-solution-r-ayo1
\tvar modifyString = function(s) {\n\t\tconst getChar = (num, left, right) => {\n\t\t\tconst char = String.fromCharCode(num);\n\t\t\treturn char === left || cha
tzuyi0817
NORMAL
2021-06-26T07:10:00.799116+00:00
2021-06-26T07:10:00.799148+00:00
130
false
\tvar modifyString = function(s) {\n\t\tconst getChar = (num, left, right) => {\n\t\t\tconst char = String.fromCharCode(num);\n\t\t\treturn char === left || char === right ? getChar(++num, left, right) : char;\n\t\t};\n\n\t\treturn [...s].reduce((acc, curr, index) => {\n\t\t\tif (curr === \'?\') {\n\t\t\t\tconst checkL...
1
0
['JavaScript']
0
replace-all-s-to-avoid-consecutive-repeating-characters
[Java] Straightforward Clean Code
java-straightforward-clean-code-by-mllej-w0tm
\nclass Solution {\n public String modifyString(String s) {\n StringBuilder str = new StringBuilder("a"+s+"z");\n for (int i = 0; i < s.length(
mllejuly
NORMAL
2021-06-13T08:50:57.540351+00:00
2021-09-25T09:26:35.579753+00:00
177
false
```\nclass Solution {\n public String modifyString(String s) {\n StringBuilder str = new StringBuilder("a"+s+"z");\n for (int i = 0; i < s.length(); i++) { \n if (s.charAt(i) == \'?\') {\n if (Math.min(str.charAt(i),str.charAt(i+2))>\'a\') {\n str.setCharAt(...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
java easy 1 ms, faster than 100.00%
java-easy-1-ms-faster-than-10000-by-tany-88zq
public String modifyString(String s) {\n StringBuilder sb = new StringBuilder();\n for(int i = 0; i < s.length(); i++){\n if(s.charAt(i
tanyasinghal92
NORMAL
2021-06-13T07:29:20.307644+00:00
2021-06-13T07:29:20.307681+00:00
198
false
public String modifyString(String s) {\n StringBuilder sb = new StringBuilder();\n for(int i = 0; i < s.length(); i++){\n if(s.charAt(i) == \'?\'){\n char ch = \'a\';\n while((i != 0 && sb.charAt(i-1) == ch) || (i != s.length() - 1 && s.charAt(i+1) ...
1
2
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python simple single pass solution, Time: O(n)
python-simple-single-pass-solution-time-otc4o
\nclass Solution:\n def modifyString(self, s: str) -> str:\n output = ""\n \n for index in range(len(s)):\n if s[index] != \'
kaushal087
NORMAL
2021-06-06T13:58:38.673070+00:00
2021-06-06T13:58:38.673115+00:00
121
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n output = ""\n \n for index in range(len(s)):\n if s[index] != \'?\':\n output += s[index] \n continue\n\n not_allowed = set()\n \n if index - 1 >= 0:\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python O(n) time | O(n) Space
python-on-time-on-space-by-wintersoldier-inxt
\n# Time = O(n)\n# Space = O(n)\nclass Solution:\n def modifyString(self, s: str) -> str:\n d = {}\n s = list(s)\n\n for i in range(len(
wintersoldier
NORMAL
2021-06-05T21:25:42.118683+00:00
2021-06-05T21:25:42.118713+00:00
92
false
```\n# Time = O(n)\n# Space = O(n)\nclass Solution:\n def modifyString(self, s: str) -> str:\n d = {}\n s = list(s)\n\n for i in range(len(s)):\n if s[i] != \'?\':\n d[s[i]] = i \n continue \n \n for j in range(1, 26+1):\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
c# solution
c-solution-by-obpb4ae4twxy-gbl0
\npublic class Solution\n{\n public string ModifyString(string s) \n {\n var c = 0;\n \n var result = new StringBuilder();\n f
obpb4ae4twxy
NORMAL
2021-06-05T16:32:45.359448+00:00
2021-06-05T16:34:15.173057+00:00
57
false
```\npublic class Solution\n{\n public string ModifyString(string s) \n {\n var c = 0;\n \n var result = new StringBuilder();\n for (int i = 0; i < s.Length; i++)\n {\n if (s[i] != \'?\')\n {\n result.Append(s[i]);\n continue;\...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
simple circular C++ 100% faster
simple-circular-c-100-faster-by-dzzhdzzh-4hzw
\nclass Solution {\npublic:\n string modifyString(string s) {\n int j = 0;\n for(int i = 0; i < s.size(); ++i){\n char c = s[i];\n
dzzhdzzh
NORMAL
2021-06-04T07:04:52.273862+00:00
2021-06-04T07:04:52.273909+00:00
59
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n int j = 0;\n for(int i = 0; i < s.size(); ++i){\n char c = s[i];\n if(c == \'?\'){\n char l = i > 0 ? s[i-1] : \'*\';\n char r = i < s.size() - 1 ? s[i + 1] : \'*\';\n c...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
100 % :: Python | Maintain a pool of characters
100-python-maintain-a-pool-of-characters-p7hv
\nclass Solution:\n def modifyString(self, s: str) -> str:\n pool = set([chr(i) for i in range(97, 123)])\n s = list(s)\n for i in range
tuhinnn_py
NORMAL
2021-05-20T16:21:33.702338+00:00
2021-05-20T16:21:33.702391+00:00
78
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n pool = set([chr(i) for i in range(97, 123)])\n s = list(s)\n for i in range(len(s)):\n if s[i] == \'?\':\n pool -= set([s[i - 1] if i >= 1 else None, s[i + 1] if i <= len(s) - 2 else None])\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
[C++] 0ms Concise Solution | 5 lines | Beats 100% Time
c-0ms-concise-solution-5-lines-beats-100-uci6
\n string modifyString(string s) {\n for(int i = 0; i < s.length(); i++){\n if(s[i] == \'?\'){\n if((i == 0 || s[i - 1] != \
sherlasd
NORMAL
2021-05-07T16:22:31.384082+00:00
2021-05-07T16:22:31.384114+00:00
208
false
```\n string modifyString(string s) {\n for(int i = 0; i < s.length(); i++){\n if(s[i] == \'?\'){\n if((i == 0 || s[i - 1] != \'a\') && (i == s.length() - 1 || s[i + 1] != \'a\')) s[i] = \'a\'; \n else if((i == 0 || s[i - 1] != \'b\') && (i == s.length() - 1 || s[i + ...
1
0
['C', 'C++']
1
replace-all-s-to-avoid-consecutive-repeating-characters
100% faster || C++ Solution || Clean Code
100-faster-c-solution-clean-code-by-kann-hao7
\nclass Solution {\npublic:\n string modifyString(string s) {\n int n = s.size();\n for(int i = 0; i < n; i++)\n if(s[i] == \'?\')\n
kannu_priya
NORMAL
2021-04-24T09:58:08.409446+00:00
2021-04-24T09:58:08.409477+00:00
136
false
```\nclass Solution {\npublic:\n string modifyString(string s) {\n int n = s.size();\n for(int i = 0; i < n; i++)\n if(s[i] == \'?\')\n for(int c = \'a\'; c <= \'z\'; c++)\n {\n if(i-1 >= 0 && c == s[i-1]) continue;\n if(i+1...
1
0
['C', 'C++']
0
replace-all-s-to-avoid-consecutive-repeating-characters
Very Simple C++ Solution | 100% Faster 0ms
very-simple-c-solution-100-faster-0ms-by-g9i6
\nclass Solution {\npublic:\n \n char fun(char cp, char cn)\n {\n for(int i=0; i<26; i++)\n {\n char c = i +\'a\';\n
imanshul
NORMAL
2021-04-21T09:11:22.842666+00:00
2021-04-21T09:11:22.842700+00:00
56
false
```\nclass Solution {\npublic:\n \n char fun(char cp, char cn)\n {\n for(int i=0; i<26; i++)\n {\n char c = i +\'a\';\n if(cp!=c && cn!=c)\n {\n return c;\n }\n }\n return 0;\n }\n string modifyString(string s) {\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
simple C++ solution
simple-c-solution-by-tuhin12-qe3o
\nclass Solution {\npublic:\n string modifyString(string s) \n {\n int len=s.length();\n char ch;\n \n for(int i=0;i<len;i++)\
Tuhin12
NORMAL
2021-04-16T15:26:44.668879+00:00
2021-04-16T15:26:44.668917+00:00
66
false
```\nclass Solution {\npublic:\n string modifyString(string s) \n {\n int len=s.length();\n char ch;\n \n for(int i=0;i<len;i++)\n {\n ch=\'a\';\n if(s[i]==\'?\')\n {\n if(i==0)\n {\n while(ch==s[i...
1
1
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Javascript using charCode and .slice
javascript-using-charcode-and-slice-by-k-um9a
\nvar modifyString = function(s) {\n for(let i = 0; i < s.length; i++){\n if(s[i] === \'?\'){\n let charCode = 97\n const charCo
kziechmann
NORMAL
2021-04-14T05:12:03.037124+00:00
2021-04-14T05:12:03.037154+00:00
47
false
```\nvar modifyString = function(s) {\n for(let i = 0; i < s.length; i++){\n if(s[i] === \'?\'){\n let charCode = 97\n const charCodeLeft = s.charCodeAt(i-1)\n const charCodeRight = s.charCodeAt(i+1)\n while(charCodeLeft === charCode || charCodeRight === charCode){\...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Elegant Python Solution
elegant-python-solution-by-true-detectiv-buur
\nclass Solution:\n def modifyString(self, s: str) -> str:\n alphabet = set(string.ascii_lowercase)\n \n res = \'\'\n for i in ra
true-detective
NORMAL
2021-04-06T14:27:16.042049+00:00
2021-04-06T14:28:32.998979+00:00
133
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n alphabet = set(string.ascii_lowercase)\n \n res = \'\'\n for i in range(len(s)):\n if s[i] != \'?\':\n res += s[i]\n continue\n \n last_char = res[-1] if i > 0 el...
1
1
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Java solution faster than 100%
java-solution-faster-than-100-by-bhavyas-wfo4
We dont want consecutive characters and multiple solutions are possible, so all we need to check is whether the character we replace is not the same as its left
bhavyaspatel
NORMAL
2021-03-29T19:24:50.359444+00:00
2021-03-29T19:24:50.359489+00:00
179
false
We dont want consecutive characters and multiple solutions are possible, so all we need to check is whether the character we replace is not the same as its left/right neighbor.\nWe can simply solve this problem by checking with 3 alphabets : \'a\', \'b\' and \'c\'\nIf left is null, check 2nd character\nelse if right is...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
[C++] Concise Solution Using string::find
c-concise-solution-using-stringfind-by-k-rgvq
Search for every ? in the string, assigning it either a, b, or c depending on the adjacent values.\n\nstring modifyString(string s) {\n\tfor (int i = s.find(\'?
KasraCode
NORMAL
2021-03-23T18:18:14.373828+00:00
2021-03-23T18:18:14.373857+00:00
38
false
Search for every `?` in the string, assigning it either `a`, `b`, or `c` depending on the adjacent values.\n```\nstring modifyString(string s) {\n\tfor (int i = s.find(\'?\'); i != string::npos; i = s.find(\'?\', i + 1)) {\n\t\tchar prev = i > 0 ? s[i - 1] : 0, next = i < s.size() - 1 ? s[i + 1] : 0;\n\t\ts[i] = (prev ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python O(n)
python-on-by-shacoz-l3z0
\nclass Solution:\n def modifyString(self, s: str) -> str:\n a_to_z = "abcdefghijklmnopqrstuvwxyz"\n ans = ""\n for i in range (0,len(s)
ShacoZ
NORMAL
2021-03-03T06:40:47.457914+00:00
2021-03-03T06:40:47.457950+00:00
109
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n a_to_z = "abcdefghijklmnopqrstuvwxyz"\n ans = ""\n for i in range (0,len(s)):\n if s[i] =="?":\n left, right ="?","?"\n if i-1 >=0 :\n left = ans[i-1]\n if i...
1
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
Python O(n) solution
python-on-solution-by-stuti2009-k38u
We can simply start with converting string in to list of characters as string is immutable in python. Then iterate over each element in list if it is "?" check
stuti2009
NORMAL
2021-03-03T05:02:04.846391+00:00
2021-03-03T05:04:37.450648+00:00
154
false
We can simply start with converting string in to list of characters as string is immutable in python. Then iterate over each element in list if it is "?" check previous and next value and replace it with any character apart from neighbours.\n \n `class Solution:\n def modifyString(self, s: str) -> str:\n ...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
Python3 solution, beat 97%
python3-solution-beat-97-by-hotrabbit05-f0m8
Python\nclass Solution:\n def modifyString(self, s: str) -> str:\n chars = \'abcdefghijklmnopqrstuvwxyz\'\n s_list = list(s)\n for i in
hotrabbit05
NORMAL
2021-02-15T03:30:37.850335+00:00
2021-02-15T03:30:37.850437+00:00
119
false
```Python\nclass Solution:\n def modifyString(self, s: str) -> str:\n chars = \'abcdefghijklmnopqrstuvwxyz\'\n s_list = list(s)\n for i in range(len(s)):\n if s_list[i] != \'?\':\n continue\n pre, post = \'\', \'\'\n if i - 1 >= 0:\n ...
1
0
[]
1
replace-all-s-to-avoid-consecutive-repeating-characters
Python Solution
python-solution-by-sunnychugh-nsmp
```\nclass Solution(object):\n def modifyString(self, s):\n """\n :type s: str\n :rtype: str\n """\n \n import rand
sunnychugh
NORMAL
2021-02-03T00:13:57.711480+00:00
2021-02-03T00:13:57.711519+00:00
133
false
```\nclass Solution(object):\n def modifyString(self, s):\n """\n :type s: str\n :rtype: str\n """\n \n import random\n import string\n def gen_char():\n char = random.choice(string.ascii_lowercase)\n return char\n \n s = lis...
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
[JAVA] Simple solution, O(n)
java-simple-solution-on-by-yurokusa-u7qc
\nclass Solution {\n public String modifyString(String s) {\n var word = s.toCharArray();\n for (int i = 0; i < word.length; i++) {\n
yurokusa
NORMAL
2021-02-02T21:40:32.419381+00:00
2021-02-02T21:40:46.057249+00:00
398
false
```\nclass Solution {\n public String modifyString(String s) {\n var word = s.toCharArray();\n for (int i = 0; i < word.length; i++) {\n if (word[i] == \'?\') {\n word[i] = \'a\';\n var left = i == 0 ? \'z\' : word[i - 1];\n var right = i == word....
1
0
['Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
easy java random solution
easy-java-random-solution-by-darkrwe-3ntv
\nclass Solution {\n Map<Integer, Character> map = new HashMap();\n Random rand = new Random();\n \n public String modifyString(String s) {\n
darkrwe
NORMAL
2021-01-06T12:12:55.530037+00:00
2021-01-06T12:13:27.258334+00:00
222
false
```\nclass Solution {\n Map<Integer, Character> map = new HashMap();\n Random rand = new Random();\n \n public String modifyString(String s) {\n char[] ch = s.toCharArray();\n map.put(0, \'a\');\n map.put(1, \'b\');\n map.put(2, \'c\');\n map.put(3, \'d\');\n map.pu...
1
1
['Java']
0
replace-all-s-to-avoid-consecutive-repeating-characters
[Java] Straightforward solution, beats 100%
java-straightforward-solution-beats-100-y0son
Time Complexity: O(n)\nSpace Complexity: O(n)\n```\nclass Solution {\n public String modifyString(String s) {\n StringBuilder sb = new StringBuilder()
Miss_S
NORMAL
2020-12-25T17:47:52.175883+00:00
2020-12-25T17:49:17.662787+00:00
154
false
Time Complexity: O(n)\nSpace Complexity: O(n)\n```\nclass Solution {\n public String modifyString(String s) {\n StringBuilder sb = new StringBuilder();\n for(int i=0;i<s.length();i++){\n if(s.charAt(i)!=\'?\'){\n sb.append(s.charAt(i));\n }else{\n sb....
1
0
[]
0
replace-all-s-to-avoid-consecutive-repeating-characters
python3 simple solution
python3-simple-solution-by-julianayo-le97
\nclass Solution:\n def modifyString(self, s: str) -> str:\n if s == \'?\':\n return \'a\'\n s_set = set(s)\n available_chars
JulianaTsv
NORMAL
2020-12-13T09:26:24.593259+00:00
2020-12-13T09:51:57.842396+00:00
480
false
```\nclass Solution:\n def modifyString(self, s: str) -> str:\n if s == \'?\':\n return \'a\'\n s_set = set(s)\n available_chars = set()\n for char in s:\n if char == \'?\':\n if not available_chars:\n available_chars = set(\'abcdefg...
1
0
['Python3']
0