Given a string that represents a mathematical expression operating on one-digit integers, compute the result


  • 0
    B

    The result must be with floating point precision. Ensure that your solution follows the order of operations.
    Example inputs and outputs are:
    input: "2", output: 2.0
    input: "2+2" output: 4.0
    input: "2*2+1", output: 5.0
    input: "1+3*5", output: 16.0
    input: "1+3*6+3*2+1", output: 26.0
    input "3-5*2", output: -7.0
    input "3-5*2/3+1", output: 0.6667


  • 0

    No parentheses? LeetCode's Basic Calculator II: https://leetcode.com/problems/basic-calculator-ii/


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.