Skip to content

Instantly share code, notes, and snippets.

@samandar-boymurodov
Created June 7, 2021 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samandar-boymurodov/bfc7b82f459869f2f9dca0a67c12578a to your computer and use it in GitHub Desktop.
Save samandar-boymurodov/bfc7b82f459869f2f9dca0a67c12578a to your computer and use it in GitHub Desktop.
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function(x) {
return x.toString().split("").reverse().join("") === x.toString()
};
@samandar-boymurodov
Copy link
Author

var isPalindrome = function(x) {
    const arr = String(x).split('');
        
    while (arr.length > 1) {
        if (arr.shift() !== arr.pop()) {
            return false;
        }
    }
    
    return true;
};

I loved this solition. because it so easy to read and understand. also it is faster than 97.26% of submitted answers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment