Binary Tree Traversal: preorder, inorder, post order recursion template: def traversal(root): # none or leaf if not root: # do sth # divide left = traversal(root.left) right = traversal(root.right) # Conquer res = # merge return res iterative template: Details see: https://www.jianshu.com/p/456af5480cee preorder example: postorder Recursion Type: … Continue reading Leetcode Tree Summary
Category: Coding interview
Leetcode Dymanic Programming Problems Summary 动态规划总结
What is dynamic programming (DP) ? Has optimal substructure: can be broken into subproblems and find solutions to subproblems Subproblems are used multiple times : use memorization to compute only once and save time. Subproblem solutions will not change Top down:DFS + memorization Bottom up: DP Steps to Solve DP Definition of … Continue reading Leetcode Dymanic Programming Problems Summary 动态规划总结