LeetCode8——String to Integer (atoi)(自己编写atoi函数)
生活随笔
收集整理的這篇文章主要介紹了
LeetCode8——String to Integer (atoi)(自己编写atoi函数)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
題目:
參考解法:
I think we only need to handle four cases:
discards all leading whitespaces
sign of the number
overflow
invalid input
注意這里的判斷條件:
base == INT_MAX / 10 && ?(str[i] - '0' > 7),最后一個為什么是這個?
總結
以上是生活随笔為你收集整理的LeetCode8——String to Integer (atoi)(自己编写atoi函数)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 6个逆向工程软件
- 下一篇: java简历模板百度网盘,再不了解你就o