The test case "+-2", why is expected 0

  • 0

    Why there is the test case like +-2? It is meaningless.

  • 0

    the result is 0 because this is not a valid string.
    A valid string can have multiple white spaces and an optional sign (+ or -) and then digits.
    This test is interesting if in your loop you don't handle this specific case.

Log in to reply

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