Solution to Word Search II by LeetCode

1 Feb


Question Name: Word Search II

In general, this is a question with DFS/BFS of graph. Additionally, we need some optimizations:

  • Use prefix tree to terminate the search early;
  • Remove the found word in the prefix tree;
  • Use bigrams to filter out the impossible words before constructing prefix tree;
  • Convert the string (a list of chars) to a list of int, which is used as index of prefix tree node.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!