DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
medium
Stack

Evaluate Reverse Polish Notation

**Problem Statement:** Given the required input arguments, write an efficient algorithm to solve the **Evaluate Reverse Polish Notation** problem. Implement the required logic as specified by standard definitions for this classic algorithmic challenge. **Hint / Expected Approach:** Push operands, pop two on operator **Edge Cases to Consider:** - (1) Single token - (2) Division with negative truncation - (3) Only operators (invalid)

Examples

Example 1
Input: ["2","1","+","3","*"]
Output: 9
Explanation: (2+1)*3
Example 2
Input: ["4","13","5","/","+"]
Output: 6
Explanation: 4+(13/5)=4+2=6
Example 3
Input: ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]
Output: 22
Explanation: Complex

Constraints

  • ▪Input arguments are within valid ranges
  • ▪Optimize for execution speed
  • ▪Handle null/empty inputs gracefully

Watch Out For Edge Cases

  • ▪Single token
  • ▪Division with negative truncation
  • ▪Only operators (invalid)
Frequently Asked At
AmazonMicrosoftGoogleAdobe