Challenge 1: Basic Trie - insert
and search
methods
#51
winterrdog
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
@winterrdog Your implementation is spot on. I'd like to suggest a couple of potential improvements, but feel free to use whichever style you prefer: First, consider using explicit if (endOfWord) newNode.isEndOfWord = true; instead of endOfWord && (newNode.isEndOfWord = true); Secondly, (and lastly) string/array lengths are more commonly visualized as const isLastChar = i === word.length - 1 instead of const isLastChar = i + 1 === word.length These are just suggestions that you might find helpful, but use whatever style you're most comfortable with. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
my solutions for EXERCISE 1 − IMPLEMENTING A TRIE (Chapter 7).
After reading through the problem, i came up with my own
insert
andsearch
functions that are iterative( one stack frame to babysit ) then later viewed the author's solution. Here's are my methods to the problem:if there's sth that needs a change i'll be glad to listen
( i'll be all ears in fact )@ishtms thanks a ton for this compilation btw 👍 i luv it 💯
Beta Was this translation helpful? Give feedback.
All reactions