Skip to content

July 21, 2025 - Daily Drill

🎯 Daily Goals

  • Review Anki Deck
  • Lumosity training
  • Leetcode
  • Developing laplace

📝 What I learned:

Leetcode problem

79. Word Search

Thinking Process

Another backtrack problem. Just iterate through all cells and perform a dfs search on each of them. If there is a match we return True. If none, we return False.

Key Takeaways

  • Notice sometimes you can reuse the input 2D matrix as a visited matrix. Here you can mark any cell that you have visited as #.
  • Remember to restore the visited marker when you backtrack.

Complexity Analysis

Denote the number of cells as n and the length of word as L.

Time Complexity: O(n*3LL) Space Complexity: O(L)

We iterate through all cells to perform a DFS. The DFS has at most 3L calculation, since we have three direction to go at each level and there is L level at most. For the space, we only uses the recursion stack which has the same depth as the word.

🚀 Resources that Requires Further Study: