241. Different Ways to Add Parentheses π₯
Medium
Problem:
Input: expression = "2*3-4*5"
Output: [-34,-14,-10,-10,10]
Explanation:
(2*(3-(4*5))) = -34
((2*3)-(4*5)) = -14
((2*(3-4))*5) = -10
(2*((3-4)*5)) = -10
(((2*3)-4)*5) = 10What to learn:
eval()
>>> '4+5'
'4+5'
>>> eval('4+5')
9append() vs. extend()
Solution:
Last updated