Pergunta de entrevista da empresa LinkedIn

How to check if the string is palindrome ?

Respostas da entrevista

Sigiloso

9 de jul. de 2018

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

1

Sigiloso

9 de jul. de 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

Sigiloso

11 de mar. de 2020

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

Sigiloso

6 de jun. de 2018

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