MCPcopy Index your code
hub / github.com/qiyuangong/leetcode / hashCode

Method hashCode

python/249_Group_Shifted_Strings.py:16–30  ·  view source on GitHub ↗
(self, string)

Source from the content-addressed store, hash-verified

14 return dic.values()
15
16 def hashCode(self, string):
17 if string is None or len(string) == 0:
18 return ''
19 if len(string) == 1:
20 return 'a'
21 step = abs(ord(string[0]) - ord('a'))
22 if step == 0:
23 return string
24 key = 'a'
25 for ch in string[1:]:
26 curr = ord(ch) - step
27 if ord(ch) - step < ord('a'):
28 curr += 26
29 key += chr(curr)
30 return key

Callers 2

groupStringsMethod · 0.95
idxMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected