Stack-Based String Evaluator (PUSH/POP/DUP/+/-)

Given a string S consisting of space-separated tokens:

  • Integers (possibly multi-digit)
  • Operators + and -
  • Commands DUP and POP

Process tokens left to right using a stack:

  • Integer: pu...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: