Pregunta de entrevista de LinkedIn

How to check if the string is palindrome ?

Respuestas de entrevistas

Anónimo

9 jul 2018

function isPalindrome(s) { if (!s) return s; if (s.length == 0) return false; let i = s.length - 1; }

1

Anónimo

9 jul 2018

function isPalindrome(s) { if (!s) return s; if (s.length == 0) return false; let i = s.length - 1; let j = 0; while (j < i) { if (s.charAt(i) !== s.charAt(j)) return false; i--; j++; } } function isPalindrome2(s) { if (!s) return s; if (s.length == 0) return false; return s == s.split('').reverse().join('') } // Add toLowerCase() if the check is case insensitive

Anónimo

11 mar 2020

S.split('').reverse().join('') === S You guys might be overthinking this one.

Anónimo

6 jun 2018

is_palindrome('aba'); // true is_palindrome('racecar'); // true is_palindrome(' aba '); // true