Example 1
Input
evaluate_rpn(['2','1','+','3','*'])
Output
9
(2 + 1) * 3 = 9
Full lesson preview
Compute the value of an expression given in Reverse Polish Notation using a stack.
Problem statement
Task
Examples
Input
evaluate_rpn(['2','1','+','3','*'])
Output
9
(2 + 1) * 3 = 9
Input format
Output format
Constraints
Samples
Input
evaluate_rpn(['4','13','5','/','+'])
Output
6
13 / 5 = 2 (truncated), 4 + 2 = 6