Solution in Golang


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

Log in to reply
 

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