leetcode 318 Maximum Product of Word Lengths
来源:互联网 发布:ubuntu系统运行py文件 编辑:程序博客网 时间:2024/06/06 00:50
int maxProduct(vector<string>& words) { vector<int> mask(words.size());//用来存储每个字符串做差后对应的int值 int res=0; int tem;//临时长度变量 for(int i=0;i<words.size();i++)//遍历words中的每个字符串 { for(int j=0;j<words[i].size();j++)//遍历每个字符串中的每个字母 { mask[i]|=(1<<(words[i][j]-'a'));//将每个字符串转化为整数 } } for(int i=0;i<words.size();i++) { for(int j=0;j<i;j++) { if(!(mask[i]&mask[j]))//相与后为0,说明没有公共的字母 { tem = words[i].size()*words[j].size(); res = max(tem,res);//取最大值 } } } return res; }
0 0
- [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 Maximum Product of Word Lengths
- Leetcode: Maximum Product of Word Lengths
- 【leetcode】318. Maximum Product of Word Lengths
- leetcode Maximum Product of Word Lengths
- leetcode -- Maximum Product of Word Lengths -- 重点
- Maximum Product of Word Lengths | LeetCode
- Leetcode: Maximum Product of Word Lengths
- LeetCode:Maximum Product of Word Lengths
- Leetcode: Maximum Product of Word Lengths
- 图 —— 特殊状态下的讨论
- 为coreseek添加mmseg分词
- SQLite并发操作下的分析与处理,解决database is locked,以及多线程下执行事务等问题
- php获取数组的长度的方法
- AJAX学习笔记
- leetcode 318 Maximum Product of Word Lengths
- js函数
- zookeeper应用——集中配置管理系统的实现
- Android App 的设计架构:MVC、MVP、MVVM 与架构经验谈
- bash shell 的变量处理
- z-index
- HashMap方法介绍
- 使用zkweb维护zookeeper数据
- jquery插件dataTable. 添加一行记录---触发click()事件