Recently, i got one question from a company in shanghai. Use Swift to write a calculator that support Arithmetic. A simple question, right?
First i write this project use a lot of if(judge different operator), you know it’s very bad!
So, i google some algorithm about arithmetic. Reverse Polish notation can help us to slove this question efficiently!
Truth be told, Firstly i read some articles about introduction for this algorithm, i still can’t write the specific code, it’s such a shame?
But i will not give up, so i read this ariticles again. After several times, i write the algorithm on my own, and my code lines just about 200. Now i realize the importance of algorithm, it’s every codeMan should be mastered.