Different ways add parentheses
Your task
Given a string expr (length 1..20) containing non-negative integers and the operators '+', '-', and '*', compute all possible results from grouping the numbers and operators with different parenthesizations. Return the distinct multiset of results sorted ascending (results may repeat for different groupings, and you should keep each occurrence). The input is a valid expression with single-digit or multi-digit operands.
Examples
diff_ways_to_compute(expr: str) -> list[int]Example 1
Input
diff_ways_to_compute("2-1-1")Output
[0, 2]