We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
for i in range(n):
count += 1
j = i
if i < n - 1:
if s[i] == s[i+1]:
while s[j+1] == s[i]:
count += 1
# if j < n - 2:
j += 1
if j == n - 1:
break
if i < n - 2:
if s[i] != s[i+1] and s[i] == s[i+2]:
while s[j+2] == s[i] and s[i-m] == s[i]:
count += 1
j += 1
if j == n - 2:
break
m += 1
m = 0
return count
Cookie support is required to access HackerRank
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 →
PYTHON SOLUTION
def substrCount(n, s): count = 0 m = 0