I was trying this question using python.
Above test case is wrong, even python int(" -0012a42") gives error on this,(in our case this should return 0)
PLEASE CORRECT TEST CASES OR GIVE PROPER EXPLAINATION!
I agree with the above post. Why should "-0012a42" evaluate to -12? I thought the intention of the problem was to verify whether the given string can be converted to a valid int or not. If these cases are true, there could be infinitely many ways of extracting a number out of the given string. For example, what stops us from evaluating the above string to "-1242"?
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.