1768. Design an Expression Tree With Evaluate Function

Medium
Array
Math
Stack
Tree
Design
Binary Tree

Description

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.

Statistics

Acceptance
82.4%
Submissions
35,544
Accepted
29,297