Tap here to switch tabs
Problem
Submissions

Problem: Optimal Division

med
30 min
Try to solve the Optimal Division problem.

Statement

You are given an integer array nums. The adjacent elements in nums represent a sequence of floating point divisions, evaluated from left to right. For example, [2, 3, 4] corresponds to the expression 2/3/42 / 3 / 4.

You may add any number of parentheses at any position to change the precedence of the operations. Determine the placement of parentheses that maximizes the evaluated result of the expression.

Return the expression that produces the maximum value as a string.

Note: Any redundant parentheses that do not influence the order of operations must be omitted.

Constraints:

  • 1≤1 \leq nums.length ≤10\leq 10

  • 2≤2 \leq nums[i] ≤1000\leq 1000

  • There is only one optimal division for the given input.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Optimal Division

med
30 min
Try to solve the Optimal Division problem.

Statement

You are given an integer array nums. The adjacent elements in nums represent a sequence of floating point divisions, evaluated from left to right. For example, [2, 3, 4] corresponds to the expression 2/3/42 / 3 / 4.

You may add any number of parentheses at any position to change the precedence of the operations. Determine the placement of parentheses that maximizes the evaluated result of the expression.

Return the expression that produces the maximum value as a string.

Note: Any redundant parentheses that do not influence the order of operations must be omitted.

Constraints:

  • 1≤1 \leq nums.length ≤10\leq 10

  • 2≤2 \leq nums[i] ≤1000\leq 1000

  • There is only one optimal division for the given input.