Meta interview question

Calculator question on Leetcode. Difficult to finish within 20 mins