LeetCode All Problems Solution Index: Backtracking, Greedy and DP

Overview

I have summarized the solutions to LeetCode problems by organizing them into closely related categories (backtracking, greedy and DP) and give tree index page for quick references.

LeetCode All Problems Solution Index: Backtracking, Greedy and DP

  1. Game Problems: Solve a game, DFS + Prune, validate a solution, e.g., N-queens, Combination sum, Permutations, Sudoku, 24 points and so on.
  2. Backtracking (DFS): Be careful about duplicates, and maybe you need to do push_back() before recursively call dfs(), and then do not forget pop_back() afterwards. Pruning could be adopted to make it more efficiently.
  3. Greedy: Need clever mind and find the optimal sub-structure
  4. Dynamic Programming: The Recursive DP function is the key! Memory Optimization is also interesting when current state only depends on previous step (e.g., n - 1) rather than all the previous states

Summary

I have summarized the solutions to LeetCode problems by organizing them into closely related categories (backtracking, greedy and DP) and give tree index page for quick references. I will keep updating the content as well as this index page as time goes. Please feel free to leave any comments.

Written on March 26, 2015