8000 Total Runtime: 323 ms · FantasyNew/LintCode_Python@da459c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit da459c2

Browse files
committed
1 parent 697eeaa commit da459c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Hash_Function.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
"""
3+
@param key: A String you should hash
4+
@param HASH_SIZE: An integer
5+
@return an integer
6+
"""
7+
def hashCode(self, key, HASH_SIZE):
8+
result = 0
9+
for c in key:
10+
result = (result * 33 + ord(c)) % HASH_SIZE
11+
12+
return result

0 commit comments

Comments
 (0)
0