题目: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: Input: "2-1-1" Output: [0, 2] Explanation: ((2…
Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. The valid operators are +, - and *. Example 1: Input: "2-1-1" Output: [0, 2] Explanation: ((2-1)-…
题目描述: 方法:分治* class Solution: def diffWaysToCompute(self, input: str) -> List[int]: if input.isdigit(): return [int(input)] tem = [] for k in range(len(input)): if input[k] == '+': tem.extend([i + j for i in self.diffWaysToCompute(input[:k]) for j in…