File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed
main/java/com/thealgorithms/stacks
test/java/com/thealgorithms/stacks Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -37,12 +37,10 @@ public boolean checkPalindrome(String string) {
37
37
// Iterate through the string
38
38
for (int i = 0 ; i < lowercase .length (); ++i ) {
39
39
char c = lowercase .charAt (i );
40
- if (c >= 'a' && c <= 'z' ) {
41
- // Build the string from L->R
42
- stringBuilder .append (c );
43
- // Push to the stack
44
- stack .push (c );
45
- }
40
+ // Build the string from L->R
41
+ stringBuilder .append (c );
42
+ // Push to the stack
43
+ stack .push (c );
46
44
}
47
45
48
46
// The stack contains the reverse order of the string
Original file line number Diff line number Diff line change @@ -59,7 +59,19 @@ public void testBlankString() {
59
59
60
60
@ Test
61
61
public void testStringWithNumbers () {
62
- String testString = "bio123ib" ;
62
+ String testString = "12321" ;
63
+ assertTrue (palindromeChecker .checkPalindrome (testString ));
64
+ }
65
+
66
+ @ Test
67
+ public void testStringWithNumbersTwo () {
68
+ String testString = "12325" ;
69
+ assertFalse (palindromeChecker .checkPalindrome (testString ));
70
+ }
71
+
72
+ @ Test
73
+ public void testStringWithNumbersAndLetters () {
74
+ String testString = "po454op" ;
63
75
assertTrue (palindromeChecker .checkPalindrome (testString ));
64
76
}
65
77
}
You can’t perform that action at this time.
0 commit comments