You are viewing a single comment's thread. Return to all comments →
Javascript
function substrCount(n, s) { let unique = new Set() for (let i = 0; i < s.length; i++) { let j = i while (s[j] == s[i]) { unique.add(i + '-' + j) j++ } let k = 1 while (i - k >= 0 && i + k <= s.length && s[i + k] == s[i - k] && (k == 1 || s[i + k] == s[i + k - 1])) { unique.add((i - k) + '-' + (i + k)) k++ } } return unique.size }
Seems like cookies are disabled on this browser, please enable them to open this website
Special String Again
You are viewing a single comment's thread. Return to all comments →
Javascript