You are viewing a single comment's thread. Return to all comments →
def substrCount(n, s): specials = len(s) i = 0 while i < len(s): repeated = 0 while i < len(s)-1 and s[i] == s[i+1]: repeated += 1 i += 1 i += 1 specials += int((repeated * (repeated + 1)) / 2) pointer = 1 while i-pointer >= 0 and i+pointer < len(s) and s[i-pointer] == s[i+pointer] and s[i-1] == s[i+pointer]: specials += 1 pointer += 1 return specials
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 →