Paranthesis Everywhere

Given an string of numbers and operators A.

Return an array containing all possible results from computing all the different possible ways to group numbers and operators in any order.

The valid operators are +, - and ***.


**Input Format

The only argument given is the string A.

Output Format

Return an array containing all possible results from computing all the different possible ways to group numbers and operators in any order. .

Constraints

1 <= number of operators in the string <= 11
0 <= Range of numbers in string <= 1000

For Example

Input 1:
    A = "2*3-4*5"
Output 1:
    [-34, -14, -10, -10, 10]
Explaination 1:
    (2*(3-(4*5))) = -34 
    ((2*3)-(4*5)) = -14 
    ((2*(3-4))*5) = -10 
    (2*((3-4)*5)) = -10 
    (((2*3)-4)*5) = 10

Input 2:
    A = "2-1-1"
Output 2:
    [0, 2]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Paranthesis Everywhere on Interview Code Editor
Sign Up
to access hints and editorial solutions for Paranthesis Everywhere

Discussion


Loading...
Click here to start solving coding interview questions