Skip to content

Commit aa13b81

Browse files
committed
added number scopes. added test case coverage
1 parent 7611b34 commit aa13b81

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/main/java/com/thealgorithms/stacks/PalindromeWithStack.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ public boolean checkPalindrome(String string) {
3737
// Iterate through the string
3838
for (int i = 0; i < lowercase.length(); ++i) {
3939
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);
4644
}
4745

4846
// The stack contains the reverse order of the string

src/test/java/com/thealgorithms/stacks/PalindromeWithStackTest.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,19 @@ public void testBlankString() {
5959

6060
@Test
6161
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";
6375
assertTrue(palindromeChecker.checkPalindrome(testString));
6476
}
6577
}

0 commit comments

Comments
 (0)