find maximum values of an expression with addition and subtraction
Answers
Answered by
0
Given a series of numbers that are added and subtracted (for example, 4-3-5), how can I insert parentheses to find the maximum value? In my example, 4-3-5 could be:
(4-3)-5 = -4 or
4-(3-5) = +6
so the second result is the maximum. But a brute force approach will take too long for something like 4+5-8-6-3-2.
(4-3)-5 = -4 or
4-(3-5) = +6
so the second result is the maximum. But a brute force approach will take too long for something like 4+5-8-6-3-2.
Similar questions