LeetCode:atoi函数 被折腾惨了
来源:互联网 发布:sql派生表 编辑:程序博客网 时间:2024/05/29 17:56
主要是情况太多了。。。。
public int atoi(String str) {int num = 0;int sign = 1;int j = 0;while (j < str.length()) {if (str.startsWith(" ")) {str = str.substring(1);j++;} elsebreak;}if (str.startsWith("+"))str = str.substring(1);if (str.startsWith("-")) {str = str.substring(1);sign = -1;}int n = str.length();for (int i = 0; i < n; i++) {if (str.charAt(i) < '0' || str.charAt(i) > '9')break;int x = str.charAt(i) - '0';if (num > Integer.MAX_VALUE / 10|| (num == Integer.MAX_VALUE / 10 && x > Integer.MAX_VALUE % 10)) {return sign == -1 ? Integer.MIN_VALUE : Integer.MAX_VALUE;}num = num * 10 + x;}return num * sign;}
0 0
- LeetCode:atoi函数 被折腾惨了
- leetcode--8--实现atoi函数
- 我被VUE折腾惨了
- 字符串转int型atoi函数-leetcode
- leetcode 题解 自主实现atoi()函数
- 被readLine()折腾了一把
- 被readLine()折腾了一把
- 被readLine()折腾了一把
- 被readLine()折腾了一把
- 被readLine()折腾了一把
- LeetCode(atoi)实现atoi
- [Leetcode] Atoi
- Leetcode: atoi
- [LeetCode] atoi
- LeetCode Atoi
- leetcode atoi
- Leetcode--atoi
- LeetCode-Atoi
- document.body.clientHeight 和 document.documentElement.clientHeight 的区别
- Android源码分析—带你认识不一样的AsyncTask
- 题目1077:最大序列和
- 自己不擅长的事情尽量外包给别人做会让你更快成功
- Android SharedPreferences
- LeetCode:atoi函数 被折腾惨了
- Android自动提示 java和xml
- 条件语句的优化(旧)
- Bash函数的参数和返回值
- TopCoder SRM 602 Div1 第1题
- 黑马程序员 08 多线程
- K-NN算法
- Storm可靠性及事务性相关设计: Acker及Trident State
- MTK Android Driver :sensor