Why there is the test case like +-2? It is meaningless.
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.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.