lintcode:哈希函数
来源:互联网 发布:老版书旗小说软件 编辑:程序博客网 时间:2024/06/10 09:18
class Solution: """ @param key: A String you should hash @param HASH_SIZE: An integer @return an integer """ def hashCode(self, key, HASH_SIZE): # write your code here re, lenA = 0, len(key) a = map(ord, key) for i in range(lenA): re += a[i] * (33**(lenA - i - 1)) # 幂运算超时 re = re % HASH_SIZE return re def hashCode(self, key, HASH_SIZE): # # write your code here re, lenA, base = 0, len(key), 1 a = map(ord, key) for i in range(lenA): re += a[lenA - i - 1] * base % HASH_SIZE base = base * 33 % HASH_SIZE return re % HASH_SIZE
阅读全文
0 0
- 哈希函数-LintCode
- lintcode:哈希函数
- LintCode HashFunction 哈希函数
- LintCode之哈希函数
- LintCode——哈希函数
- lintcode-哈稀函数-128
- lintCode(128)——哈希函数
- LintCode
- lintcode--
- lintcode
- LintCode
- Lintcode
- LintCode(M)带min函数的栈
- LintCode Consistent Hashing(一致性哈希算法)
- LintCode Consistent Hashing II(一致性哈希算法II)
- Lintcode - Median
- Lintcode - MedianII
- Lintcode - Heapify
- ubuntu16.04 SSH服务器与win 之间互传文件以及服务器搭建
- React学习之进阶ref的必要性(十三)
- Ehcache缓存技术详解
- Express 入门
- 表单中涉及到的日期控件以及日期时间控件遇到的坑。
- lintcode:哈希函数
- 【机器学习基础】理解为什么机器可以学习1——PAC学习模型
- spark性能优化之数据倾斜
- java中的各种数据类型在内存中存储的方式
- xgboost安装/git操作
- ZooKeeper系列
- PHP发送短信验证码
- 【QT】float double的范围与精度及Qt中的qfloat16
- redis for mac make安装