How to implement a calculator is a popular interview question. To answer this question well, you need to maser Stack data structures, convert an infix notation to RPN and evaluate reverse polish notation.

Since the input is usually in infix notation, e.g. “3 + 6 * 2”, it is difficult develop a program to evaluate it directly.

In practice, we can implement a calculator algorithm into two steps:

- the first step is to convert your mathematical expressions, which is called infix notation, into Reverse Polish Notation (RPN),