mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
14 lines
173 B
Go
14 lines
173 B
Go
package leetcode
|
|
|
|
func reverse7(x int) int {
|
|
tmp := 0
|
|
for x != 0 {
|
|
tmp = tmp*10 + x%10
|
|
x = x / 10
|
|
}
|
|
if tmp > 1<<31-1 || tmp < -(1<<31) {
|
|
return 0
|
|
}
|
|
return tmp
|
|
}
|