Problem Challenge 1

We'll cover the following

Evaluate Expression (hard) #

Given an expression containing digits and operations (+, -, *), find all possible ways in which the expression can be evaluated by grouping the numbers and operators using parentheses.

Example 1:

Input: "1+2*3"
Output: 7, 9
Explanation: 1+(2*3) => 7 and (1+2)*3 => 9

Example 2:

Input: "2*3-4-5"
Output: 8, -12, 7, -7, -3 
Explanation: 2*(3-(4-5)) => 8, 2*(3-4-5) => -12, 2*3-(4-5) => 7, 2*(3-4)-5 => -7, (2*3)-4-5 => -3

Try it yourself #

Try solving this question here:

Output

0.504s

Expression evaluations: [] Expression evaluations: []

Mark as Completed
←    Back
Unique Generalized Abbreviations (hard)
Next    →
Solution Review: Problem Challenge 1