JavaScript Solution


  • 0

    I think this isn't a good problem for js.

    /**
     * @param {string} str
     * @return {number}
     */
    var myAtoi = function(str) {
        if(str.length===0||!(parseInt(str)*parseInt(str)>=0)){
            return 0;
        }
        if(parseInt(str)>2147483647){
            return 2147483647;
        }
        if(parseInt(str)<-2147483648){
            return -2147483648;
        }
        return parseInt(str);
    };
    

Log in to reply
 

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