Calculate the value of a given expression in Reverse Polish Notation.

**Definitions:**

```
{expr} = [ {expr} {expr} {operator} | {integer} ]
operand = {integer}
operator = [+, -, /, *]
```

`val_of(expr)`

:= `int_val(expr)`

if expr is integer else `val_of(operand) x val_of(operand)`

where x is the operator

**Ex 0**:

```
RPN(9) = 9
RPN(3 5 +) = 8
RPN(3 1 + 2 +) = RPN(3 1 +) + RPN(2) = 4 + 2 = 10
```

**Input Format:**

Input `expr`

is a list of strings where elements are either string of integers (ex: `3`

, `5`

) or a arithmetic operation sign (`+`

, `-`

, `/`

, `*`

).

Plase, note that results of each individual operation are guaranteed to be integers.

**Ex 1:**

```
RPN(["5", "2", "+", "6", "*"]) = ((5 + 2) * 6) = 42
```

**Ex 2:**

```
RPN([ "3", "4","*","1", "2", "+", "-"]) = (3 * 4) - (1 + 2) = 12 - 3 = 9
```

Contributed by Ali Ahmet Bingül

You are not signed in. You can only run/submit code after signing in. Create your free Codela account now!