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 8%
Steffan
#2
69 c.
Top 15%
Natanaelel
#3
71 c.
Top 23%
helbling
#4
74 c.
Top 31%
madeforlosers
#5
77 c.
Top 38%
voytxt
#6
79 c.
Top 46%
Salutations45
#7
89 c.
Top 54%
maximec-indy
#8
97 c.
Top 62%
XenThe
#9
124 c.
Top 69%
SephQ
#10
139 c.
Top 77%
Thomasdcrt
#11
169 c.
Top 85%
Mif712
#12
207 c.
Top 92%
ComputerKWasTaken
#13
656 c.
Top 100%
Alex