Leetcode String to Integer
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases.
Get yanginblack’s stories in your inbox
Join Medium for free to get updates from this writer.
Notes: It is intended for this problem to be specified vaguely (ie, no given input specs). You are responsible to gather all the input requirements up front.
特别琐碎的题目,先判断并排除space,之后判断正负号,接下来用
isNaN 判断是否为数字:注意,在JS “ ” 被判断为数字,而且是0
然后result和max (integer/10)的比较也是必要的,而且要放在NaN内部,否则会误判









