To see how Javascript simplifies the work..

  • 0

    var isPalindrome = function(x) {
    if (x.toString() === x.toString().split("").reverse().join("")){
    return true;
    return false;

  • 0

    Question says do not use extra space. If you use split() and reverse() method, JS will create extra array for them. It costs O(n) space

Log in to reply

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