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 Coalition interview questions
Similar questions at other companies
- Evaluate Reverse Polish NotationAtlassian · OAAtlassian interview questions
- Find the Value of a Postfix ExpressionExpedia · ONSITE INTERVIEWExpedia interview questions
- Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
- Logistic Regression with Gradient DescentYahoo · PHONE SCREENYahoo interview questions
- Asteroid CollisionSiemens · PHONE SCREEN
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- Billing Log with Undo and RedoReddit · PHONE SCREENReddit interview questions
- Adaptive Calibration ErrorOpenAI · PHONE SCREENOpenAI interview questions
- Random Pick with Weight Using Recorded DrawsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Reachable Transfer PositionsCitadel · PHONE SCREENCitadel interview questions