← All questions
MediumCoding

Evaluate Reverse Polish Notation

Asked atAmazon
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Split the expression into tokens.
  2. 02Push numeric tokens onto a stack.
  3. 03For an operator, pop right operand then left operand.
  4. 04Apply the operator and push the result.
  5. 05Require exactly one final stack value.

Reference answer

Then expect these follow-ups

  • How would you evaluate infix notation?

    Tests: follow-up reasoning

  • What makes postfix notation unambiguous?

    Tests: follow-up reasoning

Free to read · better with Enzo

Practice this out loud with Enzo

Enzo runs it as a mock interview, pushes back with follow-ups, and grades you on the rubric.

Next question