339 Nested List Weight Sum

--- layout: post title: "339 - Nested List Weight Sum" date: "2016-11-03" --- ##### Welcome to Subscribe On Youtube <script src="https://apis.google.com/js/platform.js"></script> [Read More]

My Notes

Common Leetcode solution templates Template - Backtracking ans = [] def dfs(start_index, path, [...additional states]): if is_leaf(start_index): ans.append(path[:]) # add a copy of the path to the result return for edge in get_edges(start_index, [...additional states]): # prune if needed if not is_valid(edge): continue path.add(edge) if additional states: update(...additional states) dfs(start_index + len(edge), path, [...additional states]) # revert(...additional states) if necessary e.g. permutations path.pop() [Read More]
Tags: .interview