Tap here to switch tabs
Problem
Submissions

Problem: Different Ways to Add Parentheses

med
30 min
Try to solve the Different Ways to Add Parentheses problem.

Statement

Given a string expression representing a valid arithmetic expression made of non negative integers and the binary operators +, -, and *, return all possible results from computing the expression by inserting parentheses in every possible way.

The returned list may be in any order, and duplicate results are allowed if different parenthesizations produce the same value.

Note: The input contains only numbers and the operators +, -, and *, and the numbers are written without an explicit sign.

Constraints:

  • 11 \leq expression.length 20\leq 20

  • expression consists of digits and the operator '+', '-', and '*'

  • All integer values in expression are in the range [0,99][0, 99]

  • The integer values in expression do not have a leading '-' or '+' denoting the sign

Tap here to switch tabs
Problem
Submissions

Problem: Different Ways to Add Parentheses

med
30 min
Try to solve the Different Ways to Add Parentheses problem.

Statement

Given a string expression representing a valid arithmetic expression made of non negative integers and the binary operators +, -, and *, return all possible results from computing the expression by inserting parentheses in every possible way.

The returned list may be in any order, and duplicate results are allowed if different parenthesizations produce the same value.

Note: The input contains only numbers and the operators +, -, and *, and the numbers are written without an explicit sign.

Constraints:

  • 11 \leq expression.length 20\leq 20

  • expression consists of digits and the operator '+', '-', and '*'

  • All integer values in expression are in the range [0,99][0, 99]

  • The integer values in expression do not have a leading '-' or '+' denoting the sign