Javascript very easy solution


  • 0
    C
    var myAtoi = function(str) {
        var match = str.match(/^\s*[\-\+]?\d+/)
        var rel = match && +match[0] || 0
        if(rel>2147483647) rel = 2147483647
        if(rel<-2147483648) rel = -2147483648
        return rel 
    };
    

Log in to reply
 

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