LeetcodeBacktrackingOn this pageBacktrackingDefinition 一種用來做Brute Force的窮舉所有可能性的算法,本質是DFS,寫起來像決策樹的中序遍歷 Pattern 使用遞迴的話,基本pattern長這樣 result = []def backtrack(path, options): if target_meet: result.append(path) return for option in options: # 做選擇 backtrack(path, options) # 撤銷選擇