C++採Catalan數的遞迴DP方式計算Leetcode 241 Different Ways to Add Parentheses
每個數字都是葉節點,而+、-、*操作則不是。算術公式的 dfs 走訪等價於其對應的帶括號的 inOrder 算式。
Every number is a leaf node, and the operations +,-,* are not. A dfs transversal for a airthmetic formula is equivalent to its corresponding inOrder transversal with parentheseses.
[codes on Leetcode]https://leetcode.com/problems/different-ways-to-add-parentheses/solutions/5806427/recursiveiterative-catalan-number-like-dp-solutionbeats-100/
[Tree/ Graph play list]https://www.youtube.com/watch?v=bna7aw7dkPY&list=PLYRlUBnWnd5Kt0-3un43cwY6yT_il8NW
[動態規劃, dynamic programming, DP playlist]https://www.youtube.com/watch?v=30yq3fmE6E8&list=PLYRlUBnWnd5K_XYUesV9oc6M9ONXII61T
沒有留言:
張貼留言