leetcode 318. Maximum Product of Word Lengths
来源:互联网 发布:算法心得 编辑:程序博客网 时间:2024/06/07 22:05
class Solution(object): def maxProduct(self, words): """ :type words: List[str] :rtype: int """ bit_len_dict = dict() for word in words: mask = 0 for c in word: mask |= (1<<(ord(c)-97)) bit_len_dict[mask] = max(len(word),bit_len_dict.get(mask,0)) res = 0 for i in bit_len_dict: for j in bit_len_dict: if i&j == 0 and bit_len_dict[i]*bit_len_dict[j] > res: res = bit_len_dict[i]*bit_len_dict[j] return res
阅读全文
0 0
- 【leetcode】318. Maximum Product of Word Lengths
- 318. Maximum Product of Word Lengths LeetCode
- [leetcode] 318. Maximum Product of Word Lengths
- LeetCode: 318. Maximum Product of Word Lengths
- LeetCode 318. Maximum Product of Word Lengths
- leetcode 318. Maximum Product of Word Lengths
- [LeetCode]318. Maximum Product of Word Lengths
- [LeetCode]318. Maximum Product of Word Lengths
- LeetCode 318. Maximum Product of Word Lengths
- LeetCode *** 318. Maximum Product of Word Lengths
- [Leetcode] 318. Maximum Product of Word Lengths
- leetcode 318. Maximum Product of Word Lengths
- [leetcode]318. Maximum Product of Word Lengths
- 【LeetCode】318. Maximum Product of Word Lengths
- [LEETCODE]318. Maximum Product of Word Lengths
- 【leetcode】318. Maximum Product of Word Lengths
- [leetcode] 318. Maximum Product of Word Lengths
- leetcode 318. Maximum Product of Word Lengths
- SQL Server连接错误(Microsoft SQL Server,Error:2)
- 大型分布式项目Springmvc+Spring+Mybatis+Maven+CMS+Redis+Solr+Linux+Nginx+单点登录、分布式缓存、负载均衡
- Mysql使用sum函数时的注意事项
- EM算法的深入理解
- Spring Boot Maven Plugin -- repackage鐩?爣
- leetcode 318. Maximum Product of Word Lengths
- setContentView前面写代码,进入页面前的操作
- 使用cookie保存用户的登录状态——初步实现
- Redis linux 安装
- 9月15线程学习
- 五分钟学GIS | Elasticsearch技术
- Android热修复方案比较
- 类加载机制之Launcher
- cmd发生系统错误5 拒绝访问解决办法