Skip to content

Commit 9caa2cc

Browse files
committed
alter case
1 parent cb1121c commit 9caa2cc

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Medium/string_to_integer_atoi.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ func myAtoi(s string) int {
2929
collectString = collectString + string(s[i])
3030
}
3131

32+
if len(collectString) >= 20 {
33+
if isNegative {
34+
return -(1 << 31)
35+
} else {
36+
return (1 << 31) - 1
37+
}
38+
}
39+
3240
resultInt, err := strconv.Atoi(collectString)
3341
if err != nil {
34-
if len(collectString) > 5 {
35-
if isNegative {
36-
return -(1 << 31)
37-
} else {
38-
return (1 << 31) - 1
39-
}
40-
}
4142
return 0
4243
}
4344

0 commit comments

Comments
 (0)