Flatten Parentheses in a Plus-Minus Expression

Asked at Oracle · Coding Questions · Difficulty: Medium · Last asked Nov 10, 2026

Given an arithmetic expression that uses single-letter variables, plus and minus signs, and parentheses nested to any depth, rewrite it without any parentheses so that it keeps exactly the same value for every assignment of numbers to the variables. For example, `a-(b-c)` becomes `a-b+c`.

Loading the problem…