BAEL-3481 - modified as per Editor Review comments.

This commit is contained in:
BudBak 2020-01-10 15:10:43 +05:30
parent eeb76f09e0
commit e59d0e481d
4 changed files with 6 additions and 6 deletions

View File

@ -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();

View File

@ -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();

View File

@ -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

View File

@ -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