GamifiedGamified challengesPracticeRaceLeaderboardPricing

Learn data structures by watching them move, then doing it yourself. Press M anytime to toggle sound.

A product of Amypo Technologies, Coimbatore.

Learn

  • All topics
  • Learning path
  • How it works
  • About dotprep

Practice

  • Practice arena
  • Daily challenge
  • Gamified challenges
  • Race mode
  • Leaderboard

Interview prep

  • Java interview
  • Coding questions
  • Company questions
  • System design
  • Jobs & careers

You

  • Dashboard
  • Settings
  • Pricing
  • Create account

© 2026 dotprep

Content last updated 20 November 2026

GamifiedGamified challengesPracticeRaceLeaderboardPricing
Log inStart free
Gamified challengesPostfix Robot

Gamified challenge · Stacks

Postfix Robot

The robot's program tokens is written in postfix order: each operator comes after the two values it works on. A token is either an integer (it may be negative, like -11) or one of +, -, *, /. An operator combines the two most recent results, the older one on the left: 5 2 - means 5 - 2.

Write evalRpn(tokens) (Python: eval_rpn(tokens)) that returns the final value. Division rounds toward zero: 7 -2 / is -3, not -4. Every program is valid, never divides by zero, and every value fits in a 32-bit int.

For ["3", "4", "+", "2", "*"] the robot computes 3 + 4 = 7, then 7 * 2, so the answer is 14.

Sign in to play Postfix Robot

This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.

Sign in with Google

or log in with email · create an account