js的解法分享


  • 0
    7

    有没有人愿意分享一下
    我的是67%319ms,效率不高,求大牛们赐教
    /**
    * @param {number} x
    * @return {boolean}
    */
    var isPalindrome = function(x) {
    let str = x + "";
    for(var i=0,j=str.length-1;i<j;i++,j--){
    if(str.charAt(i) !== str.charAt(j)){
    return false;
    }
    }
    return true;
    };


Log in to reply
 

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