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

Function isPalindromeFromCenter

javascript/0647-palindromic-substrings.js:128–142  ·  view source on GitHub ↗
(s, left, right, count = 0)

Source from the content-addressed store, hash-verified

126};
127
128const isPalindromeFromCenter = (s, left, right, count = 0) => {
129 const isInBounds = () => 0 <= left && right < s.length;
130 while (isInBounds()) {
131 /* Time O(N) */
132 const isEqual = s[left] === s[right];
133 if (!isEqual) break;
134
135 count++;
136
137 left--;
138 right++;
139 }
140
141 return count;
142};

Callers 1

countSubstringsFunction · 0.85

Calls 1

isInBoundsFunction · 0.70

Tested by

no test coverage detected