Different Ways to Add Parentheses

Medium · Backtracking · about 25 minutes

Asked at Google, Amazon, Microsoft, Meta, Bloomberg.

Given an expression of numbers and the operators +, -, *, return the results of every way to fully parenthesize it, in any order (results from different groupings are all listed, even if equal).

Related guides