...
/Solution: Maximum Value of an Arithmetic Expression
Solution: Maximum Value of an Arithmetic Expression
Solution for the Maximum Value of an Arithmetic Expression Problem.
Solution
Each of the five operations in the expression
can be the last (or the outermost) one. Consider the case where the last one is “” (that is, multiplication). In this case, we need to parenthesize two subexpressions
so that the product of their values is maximized. To find this out, we find the minimum and maximum values of these two subexpressions:
From these values, we conclude that the maximum value of the product is .
Assume that the input dataset is of the form
where each is a digit and each is an arithmetic operation. The discussion above suggests that we compute the minimum value and the maximum value of each subexpression of the form
...