Evaluate Reverse Polish Notation
Updated
Problem statement
Evaluate an arithmetic expression in Reverse Polish Notation. Each operator consumes the two preceding values, and integer division truncates toward zero.
Function
evalRPN(tokens: String[]) → intExamples
Example 1
tokens = ["2","1","+","3","*"]return = 9Add 2 and 1, then multiply the result by 3.
Constraints
1 <= tokens.length <= 10000- Tokens are integers or one of
+,-,*,/. - The expression is valid and no division uses zero.
More Atlassian Online Assessment questions
- Planning ProductionOA · Seen Feb 2025
- K-Means ClusteringOA · Seen Feb 2025
- Minimum Sorted Erasure OperationsOA · Seen Jun 2024
- Count Analogous ArraysOA · Seen Mar 2024
- Get Maximum ScoreOA · Seen Mar 2024
- Better Compression 🦀OA · Seen Mar 2024
- Romanizer 🐡OA · Seen Mar 2024
- Flower Bouquets 💐OA · Seen Mar 2024
- Binary Search Tree IteratorOA · Seen Nov 2023
- Binary Tree Level Order TraversalOA · Seen Nov 2023
Similar questions at other companies
- Evaluate Reverse Polish NotationCoalition · PHONE SCREEN
- Find the Value of a Postfix ExpressionExpedia · ONSITE INTERVIEWExpedia interview questions
- Basic Calculator IITypeSafe AI · OA
- Last Object to Fall Off the TableConfluent · OAConfluent interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Count Subarrays with a Perfect-Square ProductMicrosoft · OAMicrosoft interview questions
- Repeated Mirror XORMathWorks · OAMathWorks interview questions
- Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
- Compress Editor Actions into Operational Transform OperationsReplit · OA · PHONE SCREEN · ONSITE INTERVIEW