Evaluating Expressions in Strings

You are given a string containing integers, subtraction signs (-), addition signs (+) and parenthesis representing an expression as an argument. Evaluate the "expression" and return an integer representing the result.

Requirements

  • Must return an integer
  • Should work with positive and negative numbers

Example #1

solve("2+(5-3)")
> 4

Example #2

solve("1-9-9+(-3+7+8)+2")
> -3