JavaScript Solution


  • 0
    C

    var myAtoi = function(str) {
    //如果parseInt(str)为NaN则返回0
    return Math.max(Math.min(Math.pow(2,31)-1,parseInt(str)?parseInt(str):0),-1*Math.pow(2,31));
    };


Log in to reply
 

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