New update is available. Click here to update.

Posted: 2 Nov, 2020

Difficulty: Easy

```
Infix expression: A + B * C - D
Postfix expression: A B + C D - *
```

```
1. Operators will only include the basic arithmetic operators like '*', '/', '+', and '-'.
2. The operand can contain multiple digits.
3. The operators and operands will have space as a separator between them.
4. There won’t be any brackets in the postfix expression.
```

```
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines represent the ‘T’ test cases.
The first and only line of each test case contains a postfix expression.
```

```
For each test case, print an integer obtained by evaluating the given postfix expression.
```

```
You are not required to print the expected output; it has already been taken care of, Just implement the function.
```

```
1 <= T <= 100
1 <= N <= 10^3
1 <= NUM <= 100
Where ‘N’ denotes the length of postfix expression and ‘NUM’ denotes the operand.
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Postorder Traversal

Posted: 20 Jan, 2022

Difficulty: Easy

Min Stack

Posted: 22 Jan, 2022

Difficulty: Easy

Stock Span

Posted: 16 Jun, 2022

Difficulty: Moderate

Hills and Soldier

Posted: 7 Jul, 2022

Difficulty: Moderate

Hills and Soldier

Posted: 7 Jul, 2022

Difficulty: Moderate

Next Greater Element II

Posted: 9 Sep, 2022

Difficulty: Moderate

Popular Interview Problems: