File tree Expand file tree Collapse file tree 1 file changed +1
-13
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +1
-13
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ public class _1544 {
6
6
public static class Solution1 {
7
7
public String makeGood(String s) {
8
8
Stack<Character> stack = new Stack<>();
9
- for (int i = 0; i < s.length() - 1 ; i++) {
9
+ for (int i = 0; i < s.length(); i++) {
10
10
char c = s.charAt(i);
11
11
if (stack.isEmpty()) {
12
12
stack.add(c);
@@ -24,18 +24,6 @@ public String makeGood(String s) {
24
24
}
25
25
}
26
26
}
27
- char c = s.charAt(s.length() - 1);
28
- if (!stack.isEmpty() && Character.toLowerCase(stack.peek()) == Character.toLowerCase(c)) {
29
- if ((Character.isLowerCase(stack.peek()) && Character.isUpperCase(c))) {
30
- stack.pop();
31
- } else if (Character.isUpperCase(stack.peek()) && Character.isLowerCase(c)) {
32
- stack.pop();
33
- } else {
34
- stack.add(c);
35
- }
36
- } else {
37
- stack.add(c);
38
- }
39
27
StringBuilder sb = new StringBuilder();
40
28
while (!stack.isEmpty()) {
41
29
sb.append(stack.pop());
You can’t perform that action at this time.
0 commit comments