<jupyter_start><jupyter_text>给定一个含有数字和运算符的字符串，为表达式添加括号，改变其运算优先级以求出不同的结果。    你需要给出所有可能的组合的结果。有效的运算符号包含 +, - 以及 * 。示例 1:    输入: "2-1-1"    输出: [0, 2]    解释:         ((2-1)-1) = 0         (2-(1-1)) = 2示例 2:    输入: "2*3-4*5"    输出: [-34, -14, -10, -10, 10]    解释:         (2*(3-(4*5))) = -34         ((2*3)-(4*5)) = -14         ((2*(3-4))*5) = -10         (2*((3-4)*5)) = -10         (((2*3)-4)*5) = 10<jupyter_code>class Solution:
    def diffWaysToCompute(self, inputs: str):
        res, val1, val2 = [], [], []
        for i in range(len(inputs)):
            if inputs[i] not in {'+', '-', '*'}:
                continue
            val1 = self.diffWaysToCompute(inputs[:i])
            val2 = self.diffWaysToCompute(inputs[i+1:])
            for a in val1:
                for b in val2:
                    a, b = int(a), int(b)
                    if inputs[i] == '+':
                        res.append(a + b)
                    elif inputs[i] == '-':
                        res.append(a - b)
                    elif inputs[i] == '*':
                        res.append(a * b)
        if not res:
            res.append(str(inputs))
        return res
solution = Solution()
solution.diffWaysToCompute( "2*3-4*5")<jupyter_output>['2']
['3']
['4']
['5']
[20]
['3']
['4']
[-1]
['5']
[-17, -5]
['2']
['3']
[6]
['4']
['5']
[20]
['2']
['3']
['4']
[-1]
['2']
['3']
[6]
['4']
[-2, 2]
['5']
[-34, -10, -14, -10, 10]
{'fraction_non_alphanumeric': 0.2369165487977369, 'fraction_numerical': 0.0785007072135785, 'mean_word_length': 1.5727272727272728, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '440346', 'license': 'Apache-2.0', 'n_tokens_mistral': 661, 'n_tokens_neox': 644, 'n_words': 122, 'path': 'Divide and Conquer/1125/241. Different Ways to Add Parentheses.ipynb', 'repo_name': 'YuHe0108/Leetcode', 'size': '1414'}