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 {
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 ());
You can’t perform that action at this time.
0 commit comments