Skip to content

Conversation

AgranatMarkit
Copy link
Contributor

Added following optimizations to bypass "Time Limit Exceeded":

  1. when we add word, we can unmark node in trie to prevent redundant hashing checks in our words set. node.isWord = false
  2. in the previous case we also should remove a word from the Trie. To prevent redundant heap deallocations, it's better to "mark" an Trie node using refs property. If refs == 0, then node is deleted.

@AgranatMarkit AgranatMarkit force-pushed the main branch 2 times, most recently from a30441a to 89f538b Compare June 22, 2022 14:22
@neetcode-gh neetcode-gh merged commit 5041074 into neetcode-gh:main Jul 2, 2022
neetcode-gh added a commit that referenced this pull request Jul 2, 2022
Update 212-Word-Search-II.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants