Yu Chang Cheng’s Post

View profile for Yu Chang Cheng, graphic

I post technical interview questions every day! || Software Engineer @ Nurein Studio || MS Computer Science @ Georgia Tech || MS AAE & CSE @ Purdue || Looking for Software Development Engineer / Data Engineer, Analyst

212. Word Search II Note: Use Tries and backtracking DFS to iterate over all the words. EndofWord is set to false during DFS to prevent duplicates but since we are using set() for result so technically the answer will be the same. TC: ~O(S * 3^L), where S is the number of cells on the board and L is the length of the longest word due to in DFS we only have 3 directions to search after the initial DFS. SC: O(N * L), where N is the number of words and L is the average length of the words.

  • graphical user interface, text, application
Ishaan Agrawal

fullstack @ extend.app (we're hiring!)

4mo

nice! don’t forget to include n in your TC as you iterate over the words at the beginning too, so you do an N*L operation at the beginning to populate the trie

To view or add a comment, sign in

Explore topics