MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / validPalindrome

Function validPalindrome

javascript/0680-valid-palindrome-ii.js:5–20  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

3 * @return {boolean}
4 */
5var validPalindrome = function (s) {
6 let l = 0;
7 let r = s.length - 1;
8
9 while (l < r) {
10 console.log(l, r);
11 if (s[l] !== s[r]) {
12 const skipL = s.slice(l + 1, r + 1);
13 const skipR = s.slice(l, r);
14 return isPalindrome(skipL) || isPalindrome(skipR);
15 }
16 l++;
17 r--;
18 }
19 return true;
20};
21
22const isPalindrome = (s) => {
23 let l = 0;

Callers

nothing calls this directly

Calls 1

isPalindromeFunction · 0.70

Tested by

no test coverage detected