The string expression contains nonnegative integers separated by +, -, or *. Insert parentheses in every possible way that fully specifies the order of the binary operations, without changing the order of the numbers or operators. Return one result for each grouping, in any order. Keep repeated values when different groupings produce the same result.
Example 1:
Input: expression = "3-2-1"
Output: [0,2]Explanation: The grouping (3 - 2) - 1 gives 0. The grouping 3 - (2 - 1) gives 2. Return both results.
Example 2:
Input: expression = "2+3*4"
Output: [14,20]Explanation: The grouping (2 + 3) * 4 gives 20, while 2 + (3 * 4) gives 14. Either order of these two results is accepted.
Example 3:
Input: expression = "1+1+1"
Output: [3,3]Explanation: Both (1 + 1) + 1 and 1 + (1 + 1) give 3. They are different groupings, so the result contains two copies of 3.
Constraints:
1 <= expression.length <= 20- The expression alternates integer values and binary operators
+,-, or*. - Every input integer is between
0and99and has no sign. - Every final result fits in a signed 32-bit integer.
- There are at most
10000results, counting repeated values.