Thanks @shawngao . Python2 version here:

class Solution(object): def findSubstringInWraproundString(self, p): count = collections.defaultdict(int) if len(p)==0: return 0 if len(p)==1: return 1 continus_counter,count[p[0]] = 1, 1 for i in xrange(1,len(p)): if ord(p[i])-ord(p[i-1]) == 1 or ord(p[i])-ord(p[i-1]) ==-25: continus_counter+=1 else: continus_counter=1 count[p[i]] = max(count[p[i]] , continus_counter) return sum(count.values())Subcategories

LeetCode Weekly Contest 11