Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Eval RPN

Python data engineering interview problem. Difficulty: intermediate. Pattern: Stacks. About 14 minutes. Part of the Pro drill bank.

Evaluate a Reverse Polish Notation expression. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement eval_rpn(tokens: list) -> int for +, -, *, / (truncate toward zero).

Constraints

  • Division truncates toward zero.
  • Tokens are valid RPN.

Examples

Input: eval_rpn(['2', '1', '+', '3', '*']) Output: 9 (2+1)*3 = 9.

Topics: lakebench, python, rpn, eval.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Eval RPN

Interview-style drill: Evaluate a Reverse Polish Notation expression.

Implement `eval_rpn(tokens: list) -> int` for +, -, *, / (truncate toward zero). Example: `["2", "1", "+", "3", "*"]` → `9`. Keep the harness.