Reverse Polish Notation

Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Medium6/2/2024

Problem statement

Given an expression in Reverse Polish Notation (postfix), evaluate the value of the expression. In Reverse Polish Notation, the operators follow their operands. For example, the expression 3 10 5 + * is equivalent to 3 * (10 + 5).

The expression is given as an array either integers or operators. So, for the expression [3, 10, 5, '+', '*'] you should return 45.

The result should be rounded to the nearest integer.

Problem leaderboard

#
Size
%
Users
#1
66 c.
Top 7%
Steffan
#2
69 c.
Top 13%
Natanaelel
#3
71 c.
Top 20%
helbling
#4
74 c.
Top 27%
madeforlosers
#5
77 c.
Top 33%
voytxt
#6
79 c.
Top 40%
Salutations45
#7
88 c.
Top 47%
Europe2048
#8
89 c.
Top 53%
maximec-indy
#9
97 c.
Top 60%
XenThe
#10
124 c.
Top 67%
SephQ
#11
139 c.
Top 73%
Thomasdcrt
#12
169 c.
Top 80%
Mif712
#13
207 c.
Top 87%
ComputerKWasTaken
#14
645 c.
Top 93%
Luke
#15
656 c.
Top 100%
Alex