Solution in Go


  • 0
    J
    import "math"
    
    func reverse(x int) (out int) {
        for ; x != 0; x /= 10 {
            out = out * 10 + x % 10
            if out > math.MaxInt32 || out < -math.MaxInt32 - 1 {
                return 0
            }
        }
        return out
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.