未验证 提交 888ceabf 编写于 作者: C chenxu 提交者: GitHub

Update Solution1.java

当scanInteger函数中用while循环时,对于测试用例`+-5`不能通过,对于符号的判断应该只进行一次。
上级 4c7fabb1
......@@ -43,7 +43,7 @@ public class Solution1 {
private boolean scanInteger(char[] str) {
// 去除符号
while (index < str.length && (str[index] == '+' || str[index] == '-')) {
if (index < str.length && (str[index] == '+' || str[index] == '-')) {
index++;
}
......@@ -58,4 +58,4 @@ public class Solution1 {
// 判断是否存在整数
return index > start;
}
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册