@@ -0,0 +1,902 @@
+# code not optimized which can be optimized easily by DP%0A%0Aclass Solution:%0A    # @param %7Bstring%7D input%0A    # @return %7Binteger%5B%5D%7D%0A    def diffWaysToCompute(self, input):%0A        s = input%0A        t = s.split()%0A        s = ''.join(t)%0A        if s.isdigit():%0A            return %5Bint(s)%5D%0A        res = %5B%5D%0A        for i in range(len(s)):%0A            if not s%5Bi%5D.isdigit():%0A                res1 = self.diffWaysToCompute(s%5B:i%5D)%0A                res2 = self.diffWaysToCompute(s%5Bi + 1:%5D)%0A                for r1 in res1:%0A                    for r2 in res2:%0A                        r1, r2 = int(r1), int(r2)%0A                        tmp = 0%0A                        if s%5Bi%5D == '*':%0A                            res.append(r1 * r2)%0A                        elif s%5Bi%5D == '+':%0A                            res.append(r1 + r2)%0A                        else:%0A                            res.append(r1 - r2)%0A        return res%0A

Create DiffWays2AddParen_001.py