File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
src/main/java/com/thealgorithms Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ public static String reverse(String str) {
22
22
return str ;
23
23
}
24
24
// Push each character of the string onto the stack
25
- for (char ch : str .toCharArray ()) {
26
- stack .push (ch );
25
+ for (char i : str .toCharArray ()) {
26
+ stack .push (i );
27
27
}
28
28
// Pop each character from the stack and append to the StringBuilder
29
29
while (!stack .isEmpty ()) {
Original file line number Diff line number Diff line change @@ -76,13 +76,14 @@ public static String reverse4(String str) {
76
76
return str ;
77
77
}
78
78
// Push each character of the string onto the stack
79
- for (char ch : str .toCharArray ()) {
80
- stack .push (ch );
79
+ for (char i : str .toCharArray ()) {
80
+ stack .push (i );
81
81
}
82
82
// Pop each character from the stack and append to the StringBuilder
83
83
while (!stack .isEmpty ()) {
84
84
reversedString .append (stack .pop ());
85
85
}
86
86
return reversedString .toString ();
87
87
}
88
+
88
89
}
You can’t perform that action at this time.
0 commit comments