Ezvor

1628. Design an Expression Tree With Evaluate Function

MediumArray Preparing judge… LeetCode
ArrayMathStackTreeDesignBinary Tree

Hints

Hint 1
Apply the concept of Polymorphism to get a good design
Hint 2
Implement the Node class using NumericNode and OperatorNode classes.
Hint 3
NumericNode only maintains the value and evaluate returns this value.
Hint 4
OperatorNode Maintains the left and right nodes representing the left and right operands, and the evaluate function applies the operator to them.