Solution in JavaScript


  • 0
    H
        if (x < 0) {
          l = -1;
        } else {
          l = 1; 
        }
        if (x > 2147483647 || x < -2147483647){
            return 0
        }
        x = x.toString(); 
        var rstring = "";
        // reverse for loop
        for(var i = x.length -1; i >=0; i--) {
          rstring = rstring + x[i]; 
        }
    
        rstring = parseInt(rstring)
        if (rstring > 2147483647 || rstring < -2147483647){
            return 0
        }
      return rstring * l; 
    };```

Log in to reply
 

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