Solution in Javascript


  • 0
    B
    var reverse = function(x) {
        var reverseNum = '';
        for (var i = x.toString().length-1; i >= 0; i--){
            reverseNum += x.toString()[i]
        }
        reverseNum = x < 0 ? - parseInt(reverseNum) : parseInt(reverseNum);
        if(reverseNum > 2147483648){
            return 0;
        }
        return reverseNum;
    };
    

Log in to reply
 

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