Skip to content

Commit d0c8c0b

Browse files
refactor 1544
1 parent cdec8f3 commit d0c8c0b

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/main/java/com/fishercoder/solutions/_1544.java

+1-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class _1544 {
66
public static class Solution1 {
77
public String makeGood(String s) {
88
Stack<Character> stack = new Stack<>();
9-
for (int i = 0; i < s.length() - 1; i++) {
9+
for (int i = 0; i < s.length(); i++) {
1010
char c = s.charAt(i);
1111
if (stack.isEmpty()) {
1212
stack.add(c);
@@ -24,18 +24,6 @@ public String makeGood(String s) {
2424
}
2525
}
2626
}
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-
}
3927
StringBuilder sb = new StringBuilder();
4028
while (!stack.isEmpty()) {
4129
sb.append(stack.pop());

0 commit comments

Comments
 (0)