Golang solution


  • 2
    Y
    func reverse(x int) int {
        var result int
        for x != 0 {
            result = result * 10 + x % 10
            x = x / 10
        }
        if result < math.MinInt32 || result > math.MaxInt32 {
            return 0
        }
        return result
    }

Log in to reply
 

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