It seems to be easy to solve this one by javascript


  • 0
    K
    var isNumber = function(s) {
        if(s===""|| s.replace(/(^\s*)/g,"")==="")
            return false;
            else
            return !isNaN(s-1);
        
    };

  • 0
    L

    even simplier

       var isNumber = function(s){
        s = s.trim();
        if(+s || +s === 0 && s !='') return true;
        return false;
        }

Log in to reply
 

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