DFS & BFS & BackTrack

Trees

Tree

DFS/BFS

DFS

  • No. 78 Subsets

  • No.90 Subsets I

BFS

BackTrack

Mixed DFS/BFS + Backtrack + Memorization ⭐️⭐️⭐️⭐️⭐️

  • 79. Word Search – DFS

    • Pruning: consider freq, can reverse the word, start from low freq.

  • 212. Word Search II – backtracking + trie

  • 329. Longest Increasing Path in a Matrix – DFS + DP memoization

  • 140. Word Break II – DFS + memoization (backtracking with DP)

  • 694. Number of Distinct Islands – DFS + canonical shape representation

  • 301. Remove Invalid Parentheses – backtracking + pruning

Last updated