Skip to content

Commit f848beb

Browse files
committed
Design Add and Search Words Data Structure - addWord() 코드 리팩토링
1 parent 7ae4344 commit f848beb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

design-add-and-search-words-data-structure/forest000014.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,10 @@ public void addWord(String word) {
3838
curr.children.put(ch, new Node(ch));
3939
}
4040

41-
if (i == word.length() - 1) {
42-
curr.children.get(ch).ends = true;
43-
} else {
44-
curr = curr.children.get(ch);
45-
}
41+
curr = curr.children.get(ch);
4642
}
43+
44+
curr.ends = true;
4745
}
4846

4947
public boolean search(String word) {

0 commit comments

Comments
 (0)