Skip to content

Commit 4083875

Browse files
author
alxkm
committed
refactor: fix redundant check
1 parent 82eb9c2 commit 4083875

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/main/java/com/thealgorithms/strings/WordLadder.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ public static int ladderLength(String beginWord, String endWord, List<String> wo
5050
if (newWord.equals(endWord)) {
5151
return level + 1;
5252
}
53-
if (wordSet.contains(newWord)) {
54-
wordSet.remove(newWord);
53+
if (wordSet.remove(newWord)) {
5554
queue.offer(newWord);
5655
}
5756
}

0 commit comments

Comments
 (0)