Make The String Great LeetCode solution in Java

1
class Solution {
2
public String makeGood(String s) {
3
char[] res = s.toCharArray();
4
int i = 0;
5
for (char n : s.toCharArray()) {
6
res[i] = n;
7

8
if (i > 0 && Math.abs((int) res[i - 1] - (int) res[i]) == 32) {
9
i -= 2;
10
}
11
i++;
12
}
13
return new String(res, 0, i);
14
}
15
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0