Algorithm · Snapchat · Medium
You are building a calculator that takes a mathematical expression as a string s and returns its integer value. The expression may include positive and negative integers, the four basic operators—addition ('+'), subtraction ('-'), multiplication (''), division ('/')—and parentheses '(' and ')'. Your calculator must obey these rules: Division always truncates toward zero. For instance, "5/2" yields 2, and "-7/3" yields -2. Negative numbers are allowed both as operands and as…