Skip to content

Commit 76874a6

Browse files
committed
feat: update java solution to problem No.1576
1 parent b787b74 commit 76874a6

File tree

3 files changed

+16
-19
lines changed

3 files changed

+16
-19
lines changed

Diff for: solution/1500-1599/1576.Replace All #003F's to Avoid Consecutive Repeating Characters/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,16 @@ class Solution:
8787

8888
```java
8989
class Solution {
90-
public String modifyString(String s) {
90+
public String modifyString(String s) {
9191
char[] chars = s.toCharArray();
92-
9392
for (int i = 0; i < chars.length; i++) {
9493
if (chars[i] == '?') {
95-
// 前面的字符
94+
// 前面的字符
9695
char ahead = i == 0 ? ' ' : chars[i - 1];
97-
// 最后的字符
98-
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
96+
// 后面的字符
97+
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
9998
char temp = 'a';
100-
while (temp == ahead || temp == behind ) {
99+
while (temp == ahead || temp == behind) {
101100
temp++;
102101
}
103102
chars[i] = temp;

Diff for: solution/1500-1599/1576.Replace All #003F's to Avoid Consecutive Repeating Characters/README_EN.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,16 @@ class Solution:
8282

8383
```java
8484
class Solution {
85-
public String modifyString(String s) {
85+
public String modifyString(String s) {
8686
char[] chars = s.toCharArray();
87-
8887
for (int i = 0; i < chars.length; i++) {
8988
if (chars[i] == '?') {
90-
// 前面的字符
89+
// 前面的字符
9190
char ahead = i == 0 ? ' ' : chars[i - 1];
92-
// 最后的字符
93-
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
91+
// 后面的字符
92+
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
9493
char temp = 'a';
95-
while (temp == ahead || temp == behind ) {
94+
while (temp == ahead || temp == behind) {
9695
temp++;
9796
}
9897
chars[i] = temp;
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
class Solution {
2-
public String modifyString(String s) {
2+
public String modifyString(String s) {
33
char[] chars = s.toCharArray();
4-
54
for (int i = 0; i < chars.length; i++) {
65
if (chars[i] == '?') {
7-
// 前面的字符
6+
// 前面的字符
87
char ahead = i == 0 ? ' ' : chars[i - 1];
9-
// 最后的字符
10-
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
8+
// 后面的字符
9+
char behind = i == chars.length - 1 ? ' ' : chars[i + 1];
1110
char temp = 'a';
12-
while (temp == ahead || temp == behind ) {
11+
while (temp == ahead || temp == behind) {
1312
temp++;
1413
}
1514
chars[i] = temp;
1615
}
1716
}
1817
return new String(chars);
1918
}
20-
}
19+
}

0 commit comments

Comments
 (0)