Find the Maximum Value by Inserting ‘+’, ’*’ and '()'

Given an array of numbers, the task is to find the maximum value from the string, you can add a ‘+’ or ‘*’ sign between any two numbers. You should also use parantheses.

Examples:

[0, 1, 2, 3, 1] can be written as (((0 + 1) + 2) * 3) + 1 = 10, therefore the output should be 10 since it is the maximum value that can be obtained.

[8, 9, 1] can be written as (8 * 9) + 1 = 73, therefore the output should be 73 since it is the maximum value that can be obtained.

Contributed by Berkan Teber