BAEL-3481 - modified as per Editor Review comments.
This commit is contained in:
parent
eeb76f09e0
commit
e59d0e481d
|
@ -6,7 +6,7 @@ import java.util.LinkedList;
|
|||
public class BalancedBracketsUsingDeque {
|
||||
|
||||
public boolean isBalanced(String str) {
|
||||
if (null == str || str.length() == 0 || ((str.length() % 2) != 0)) {
|
||||
if (null == str || ((str.length() % 2) != 0)) {
|
||||
return false;
|
||||
} else {
|
||||
char[] ch = str.toCharArray();
|
||||
|
|
|
@ -3,7 +3,7 @@ package com.baeldung.algorithms.balancedbrackets;
|
|||
public class BalancedBracketsUsingString {
|
||||
|
||||
public boolean isBalanced(String str) {
|
||||
if (null == str || str.length() == 0 || ((str.length() % 2) != 0)) {
|
||||
if (null == str || ((str.length() % 2) != 0)) {
|
||||
return false;
|
||||
} else {
|
||||
char[] ch = str.toCharArray();
|
||||
|
|
|
@ -21,9 +21,9 @@ public class BalancedBracketsUsingDequeUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenEmptyString_whenCheckingForBalance_shouldReturnFalse() {
|
||||
public void givenEmptyString_whenCheckingForBalance_shouldReturnTrue() {
|
||||
boolean result = balancedBracketsUsingDeque.isBalanced("");
|
||||
assertThat(result).isFalse();
|
||||
assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,9 +21,9 @@ public class BalancedBracketsUsingStringUnitTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void givenEmptyString_whenCheckingForBalance_shouldReturnFalse() {
|
||||
public void givenEmptyString_whenCheckingForBalance_shouldReturnTrue() {
|
||||
boolean result = balancedBracketsUsingString.isBalanced("");
|
||||
assertThat(result).isFalse();
|
||||
assertThat(result).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue