Medium · System Design
Expression Tree / Design an Expression Tree
Given a valid postfix expression as a list of tokens (non-negative integers and the operators +, -, *, /), build the corresponding binary expression tree and return the integer its root's evaluate() returns, where / truncates toward zero.
Examples
Example 1
{
"postfix": ["3", "4", "+", "2", "*"]
}Output: 14
Example 2
{
"postfix": ["10", "2", "/", "3", "+"]
}Output: 8
Rebuild it in the studio
Open every published interview problem, solution, scene, and memory room free, with no account.