mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-07 15:01:58 +08:00
fix: update the implementation of simple_hash.js and .ts (#1656)
This commit is contained in:
@ -31,7 +31,7 @@ function xorHash(key) {
|
|||||||
for (const c of key) {
|
for (const c of key) {
|
||||||
hash ^= c.charCodeAt(0);
|
hash ^= c.charCodeAt(0);
|
||||||
}
|
}
|
||||||
return hash & MODULUS;
|
return hash % MODULUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 旋转哈希 */
|
/* 旋转哈希 */
|
||||||
|
@ -31,7 +31,7 @@ function xorHash(key: string): number {
|
|||||||
for (const c of key) {
|
for (const c of key) {
|
||||||
hash ^= c.charCodeAt(0);
|
hash ^= c.charCodeAt(0);
|
||||||
}
|
}
|
||||||
return hash & MODULUS;
|
return hash % MODULUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 旋转哈希 */
|
/* 旋转哈希 */
|
||||||
|
Reference in New Issue
Block a user