Different Ways to Add Parentheses Solutions in PythonNumber 241Difficulty MediumAcceptance 55.3%Link LeetCodeOther languages C++SolutionsPython solution by haoel/leetcodedef diffWaysToCompute(self, input): return [a + b if c == '+' else a - b if c == '-' else a * b \ for i, c in enumerate(input) if c in '+-*' \ for a in self.diffWaysToCompute(input[:i]) \ for b in self.diffWaysToCompute(input[i+1:])] or [int(input)]def diffWaysToCompute(self, input): return [a + b if c == '+' else a - b if c == '-' else a * b \ for i, c in enumerate(input) if c in '+-*' \ for a in self.diffWaysToCompute(input[:i]) \ for b in self.diffWaysToCompute(input[i+1:])] or [int(input)]